Format readjson
clang-format may potentially reformat the readJson calls if they may
have more keys or key names are longer. This makes formatting in a way
that's readable by forcing to break a line for each key using an
empty-comment (`//`) each line.
It also allows trivially alphabetizing the list such that new additions
are less likely to have merge conflicts.
Tested:
- Check whitespace only.
- Code compiles.
- Redfish Service Validator with the same results before this
Change-Id: I3824a8c4faa9fa7c820d5d2fab6b565404926e2c
Signed-off-by: Ed Tanous <etanous@nvidia.com>
Signed-off-by: Myung Bae <myungbae@us.ibm.com>
diff --git a/redfish-core/lib/account_service.hpp b/redfish-core/lib/account_service.hpp
index 2ec3e32..bf32014 100644
--- a/redfish-core/lib/account_service.hpp
+++ b/redfish-core/lib/account_service.hpp
@@ -417,8 +417,11 @@
std::optional<std::string> remoteGroup;
std::optional<std::string> localRole;
- if (!json_util::readJsonObject(*obj, asyncResp->res, "RemoteGroup",
- remoteGroup, "LocalRole", localRole))
+ if (!json_util::readJsonObject( //
+ *obj, asyncResp->res, //
+ "LocalRole", localRole, //
+ "RemoteGroup", remoteGroup //
+ ))
{
continue;
}
@@ -1542,43 +1545,56 @@
AuthMethods auth;
std::optional<std::string> httpBasicAuth;
- // clang-format off
- if (!json_util::readJsonPatch(
- req, asyncResp->res,
- "AccountLockoutDuration", unlockTimeout,
- "AccountLockoutThreshold", lockoutThreshold,
- "ActiveDirectory/Authentication/AuthenticationType", activeDirectoryObject.authType,
- "ActiveDirectory/Authentication/Password", activeDirectoryObject.password,
- "ActiveDirectory/Authentication/Username", activeDirectoryObject.userName,
- "ActiveDirectory/LDAPService/SearchSettings/BaseDistinguishedNames", activeDirectoryObject.baseDNList,
- "ActiveDirectory/LDAPService/SearchSettings/GroupsAttribute", activeDirectoryObject.groupsAttribute,
- "ActiveDirectory/LDAPService/SearchSettings/UsernameAttribute", activeDirectoryObject.userNameAttribute,
- "ActiveDirectory/RemoteRoleMapping", activeDirectoryObject.remoteRoleMapData,
- "ActiveDirectory/ServiceAddresses", activeDirectoryObject.serviceAddressList,
- "ActiveDirectory/ServiceEnabled", activeDirectoryObject.serviceEnabled,
- "MultiFactorAuth/ClientCertificate/CertificateMappingAttribute", certificateMappingAttribute,
- "MultiFactorAuth/ClientCertificate/RespondToUnauthenticatedClients", respondToUnauthenticatedClients,
- "LDAP/Authentication/AuthenticationType", ldapObject.authType,
- "LDAP/Authentication/Password", ldapObject.password,
- "LDAP/Authentication/Username", ldapObject.userName,
- "LDAP/LDAPService/SearchSettings/BaseDistinguishedNames", ldapObject.baseDNList,
- "LDAP/LDAPService/SearchSettings/GroupsAttribute", ldapObject.groupsAttribute,
- "LDAP/LDAPService/SearchSettings/UsernameAttribute", ldapObject.userNameAttribute,
- "LDAP/RemoteRoleMapping", ldapObject.remoteRoleMapData,
- "LDAP/ServiceAddresses", ldapObject.serviceAddressList,
- "LDAP/ServiceEnabled", ldapObject.serviceEnabled,
- "MaxPasswordLength", maxPasswordLength,
- "MinPasswordLength", minPasswordLength,
- "Oem/OpenBMC/AuthMethods/BasicAuth", auth.basicAuth,
- "Oem/OpenBMC/AuthMethods/Cookie", auth.cookie,
- "Oem/OpenBMC/AuthMethods/SessionToken", auth.sessionToken,
- "Oem/OpenBMC/AuthMethods/TLS", auth.tls,
- "Oem/OpenBMC/AuthMethods/XToken", auth.xToken,
- "HTTPBasicAuth", httpBasicAuth))
+ if (!json_util::readJsonPatch( //
+ req, asyncResp->res, //
+ "AccountLockoutDuration", unlockTimeout, //
+ "AccountLockoutThreshold", lockoutThreshold, //
+ "ActiveDirectory/Authentication/AuthenticationType",
+ activeDirectoryObject.authType, //
+ "ActiveDirectory/Authentication/Password",
+ activeDirectoryObject.password, //
+ "ActiveDirectory/Authentication/Username",
+ activeDirectoryObject.userName, //
+ "ActiveDirectory/LDAPService/SearchSettings/BaseDistinguishedNames",
+ activeDirectoryObject.baseDNList, //
+ "ActiveDirectory/LDAPService/SearchSettings/GroupsAttribute",
+ activeDirectoryObject.groupsAttribute, //
+ "ActiveDirectory/LDAPService/SearchSettings/UsernameAttribute",
+ activeDirectoryObject.userNameAttribute, //
+ "ActiveDirectory/RemoteRoleMapping",
+ activeDirectoryObject.remoteRoleMapData, //
+ "ActiveDirectory/ServiceAddresses",
+ activeDirectoryObject.serviceAddressList, //
+ "ActiveDirectory/ServiceEnabled",
+ activeDirectoryObject.serviceEnabled, //
+ "HTTPBasicAuth", httpBasicAuth, //
+ "LDAP/Authentication/AuthenticationType", ldapObject.authType, //
+ "LDAP/Authentication/Password", ldapObject.password, //
+ "LDAP/Authentication/Username", ldapObject.userName, //
+ "LDAP/LDAPService/SearchSettings/BaseDistinguishedNames",
+ ldapObject.baseDNList, //
+ "LDAP/LDAPService/SearchSettings/GroupsAttribute",
+ ldapObject.groupsAttribute, //
+ "LDAP/LDAPService/SearchSettings/UsernameAttribute",
+ ldapObject.userNameAttribute, //
+ "LDAP/RemoteRoleMapping", ldapObject.remoteRoleMapData, //
+ "LDAP/ServiceAddresses", ldapObject.serviceAddressList, //
+ "LDAP/ServiceEnabled", ldapObject.serviceEnabled, //
+ "MaxPasswordLength", maxPasswordLength, //
+ "MinPasswordLength", minPasswordLength, //
+ "MultiFactorAuth/ClientCertificate/CertificateMappingAttribute",
+ certificateMappingAttribute, //
+ "MultiFactorAuth/ClientCertificate/RespondToUnauthenticatedClients",
+ respondToUnauthenticatedClients, //
+ "Oem/OpenBMC/AuthMethods/BasicAuth", auth.basicAuth, //
+ "Oem/OpenBMC/AuthMethods/Cookie", auth.cookie, //
+ "Oem/OpenBMC/AuthMethods/SessionToken", auth.sessionToken, //
+ "Oem/OpenBMC/AuthMethods/TLS", auth.tls, //
+ "Oem/OpenBMC/AuthMethods/XToken", auth.xToken //
+ ))
{
return;
}
- // clang-format on
if (httpBasicAuth)
{
@@ -1883,10 +1899,14 @@
std::optional<std::string> roleIdJson;
std::optional<bool> enabledJson;
std::optional<std::vector<std::string>> accountTypes;
- if (!json_util::readJsonPatch(
- req, asyncResp->res, "UserName", username, "Password", password,
- "RoleId", roleIdJson, "Enabled", enabledJson, "AccountTypes",
- accountTypes))
+ if (!json_util::readJsonPatch( //
+ req, asyncResp->res, //
+ "AccountTypes", accountTypes, //
+ "Enabled", enabledJson, //
+ "Password", password, //
+ "RoleId", roleIdJson, //
+ "UserName", username //
+ ))
{
return;
}
@@ -2202,10 +2222,15 @@
if (userHasConfigureUsers)
{
// Users with ConfigureUsers can modify for all users
- if (!json_util::readJsonPatch(
- req, asyncResp->res, "UserName", newUserName, "Password",
- password, "RoleId", roleId, "Enabled", enabled, "Locked",
- locked, "AccountTypes", accountTypes))
+ if (!json_util::readJsonPatch( //
+ req, asyncResp->res, //
+ "AccountTypes", accountTypes, //
+ "Enabled", enabled, //
+ "Locked", locked, //
+ "Password", password, //
+ "RoleId", roleId, //
+ "UserName", newUserName //
+ ))
{
return;
}
diff --git a/redfish-core/lib/certificate_service.hpp b/redfish-core/lib/certificate_service.hpp
index 7ae194c..f16b169 100644
--- a/redfish-core/lib/certificate_service.hpp
+++ b/redfish-core/lib/certificate_service.hpp
@@ -66,9 +66,11 @@
std::string certificate;
std::optional<std::string> certificateType = "PEM";
- if (!json_util::readJsonPatch(req, asyncResp->res, "CertificateString",
- certificate, "CertificateType",
- certificateType))
+ if (!json_util::readJsonPatch( //
+ req, asyncResp->res, //
+ "CertificateString", certificate, //
+ "CertificateType", certificateType //
+ ))
{
BMCWEB_LOG_ERROR("Required parameters are missing");
messages::internalError(asyncResp->res);
@@ -497,9 +499,12 @@
std::string certURI;
std::optional<std::string> certificateType = "PEM";
- if (!json_util::readJsonAction(req, asyncResp->res, "CertificateString",
- certificate, "CertificateUri/@odata.id",
- certURI, "CertificateType", certificateType))
+ if (!json_util::readJsonAction( //
+ req, asyncResp->res, //
+ "CertificateString", certificate, //
+ "CertificateType", certificateType, //
+ "CertificateUri/@odata.id", certURI //
+ ))
{
BMCWEB_LOG_ERROR("Required parameters are missing");
return;
@@ -670,18 +675,28 @@
std::vector<std::string>();
std::optional<std::string> optSurname = "";
std::optional<std::string> optUnstructuredName = "";
- if (!json_util::readJsonAction(
- req, asyncResp->res, "City", city, "CommonName", commonName,
- "ContactPerson", optContactPerson, "Country", country,
- "Organization", organization, "OrganizationalUnit",
- organizationalUnit, "State", state,
- "CertificateCollection/@odata.id", certURI, "AlternativeNames",
- optAlternativeNames, "ChallengePassword", optChallengePassword,
- "Email", optEmail, "GivenName", optGivenName, "Initials",
- optInitials, "KeyBitLength", optKeyBitLength, "KeyCurveId",
- optKeyCurveId, "KeyPairAlgorithm", optKeyPairAlgorithm, "KeyUsage",
- optKeyUsage, "Surname", optSurname, "UnstructuredName",
- optUnstructuredName))
+ if (!json_util::readJsonAction( //
+ req, asyncResp->res, //
+ "AlternativeNames", optAlternativeNames, //
+ "CertificateCollection/@odata.id", certURI, //
+ "ChallengePassword", optChallengePassword, //
+ "City", city, //
+ "CommonName", commonName, //
+ "ContactPerson", optContactPerson, //
+ "Country", country, //
+ "Email", optEmail, //
+ "GivenName", optGivenName, //
+ "Initials", optInitials, //
+ "KeyBitLength", optKeyBitLength, //
+ "KeyCurveId", optKeyCurveId, //
+ "KeyPairAlgorithm", optKeyPairAlgorithm, //
+ "KeyUsage", optKeyUsage, //
+ "Organization", organization, //
+ "OrganizationalUnit", organizationalUnit, //
+ "State", state, //
+ "Surname", optSurname, //
+ "UnstructuredName", optUnstructuredName //
+ ))
{
return;
}
diff --git a/redfish-core/lib/chassis.hpp b/redfish-core/lib/chassis.hpp
index a993b01..d5ca046 100644
--- a/redfish-core/lib/chassis.hpp
+++ b/redfish-core/lib/chassis.hpp
@@ -678,9 +678,11 @@
return;
}
- if (!json_util::readJsonPatch(
- req, asyncResp->res, "LocationIndicatorActive",
- locationIndicatorActive, "IndicatorLED", indicatorLed))
+ if (!json_util::readJsonPatch( //
+ req, asyncResp->res, //
+ "IndicatorLED", indicatorLed, //
+ "LocationIndicatorActive", locationIndicatorActive //
+ ))
{
return;
}
diff --git a/redfish-core/lib/ethernet.hpp b/redfish-core/lib/ethernet.hpp
index d8c5ae3..a0dcd54 100644
--- a/redfish-core/lib/ethernet.hpp
+++ b/redfish-core/lib/ethernet.hpp
@@ -1549,9 +1549,12 @@
std::optional<std::string> subnetMask;
std::optional<std::string> gateway;
- if (!json_util::readJsonObject(*obj, asyncResp->res, "Address",
- address, "SubnetMask", subnetMask,
- "Gateway", gateway))
+ if (!json_util::readJsonObject( //
+ *obj, asyncResp->res, //
+ "Address", address, //
+ "Gateway", gateway, //
+ "SubnetMask", subnetMask //
+ ))
{
messages::propertyValueFormatError(asyncResp->res, *obj,
pathString);
@@ -1728,9 +1731,11 @@
std::optional<std::string> address;
std::optional<uint8_t> prefixLength;
nlohmann::json::object_t thisJsonCopy = *obj;
- if (!json_util::readJsonObject(thisJsonCopy, asyncResp->res,
- "Address", address, "PrefixLength",
- prefixLength))
+ if (!json_util::readJsonObject( //
+ thisJsonCopy, asyncResp->res, //
+ "Address", address, //
+ "PrefixLength", prefixLength //
+ ))
{
messages::propertyValueFormatError(asyncResp->res, thisJsonCopy,
pathString);
@@ -2132,10 +2137,12 @@
uint32_t vlanId = 0;
std::vector<nlohmann::json::object_t> relatedInterfaces;
- if (!json_util::readJsonPatch(
- req, asyncResp->res, "VLAN/VLANEnable", vlanEnable,
- "VLAN/VLANId", vlanId, "Links/RelatedInterfaces",
- relatedInterfaces))
+ if (!json_util::readJsonPatch( //
+ req, asyncResp->res, //
+ "Links/RelatedInterfaces", relatedInterfaces, //
+ "VLAN/VLANEnable", vlanEnable, //
+ "VLAN/VLANId", vlanId //
+ ))
{
return;
}
@@ -2288,33 +2295,36 @@
std::optional<size_t> mtuSize;
DHCPParameters v4dhcpParms;
DHCPParameters v6dhcpParms;
- // clang-format off
- if (!json_util::readJsonPatch(req, asyncResp->res,
- "DHCPv4/DHCPEnabled", v4dhcpParms.dhcpv4Enabled,
- "DHCPv4/UseDNSServers", v4dhcpParms.useDnsServers,
- "DHCPv4/UseDomainName", v4dhcpParms.useDomainName,
- "DHCPv4/UseNTPServers", v4dhcpParms.useNtpServers,
- "DHCPv6/OperatingMode", v6dhcpParms.dhcpv6OperatingMode,
- "DHCPv6/UseDNSServers", v6dhcpParms.useDnsServers,
- "DHCPv6/UseDomainName", v6dhcpParms.useDomainName,
- "DHCPv6/UseNTPServers", v6dhcpParms.useNtpServers,
- "FQDN", fqdn,
- "HostName", hostname,
- "IPv4StaticAddresses", ipv4StaticAddresses,
- "IPv6DefaultGateway", ipv6DefaultGateway,
- "IPv6StaticAddresses", ipv6StaticAddresses,
- "IPv6StaticDefaultGateways", ipv6StaticDefaultGateways,
- "InterfaceEnabled", interfaceEnabled,
- "MACAddress", macAddress,
- "MTUSize", mtuSize,
- "StatelessAddressAutoConfig/IPv6AutoConfigEnabled", ipv6AutoConfigEnabled,
- "StaticNameServers", staticNameServers
- )
- )
- {
- return;
- }
- // clang-format on
+
+ if (!json_util::readJsonPatch( //
+ req, asyncResp->res, //
+ "DHCPv4/DHCPEnabled", v4dhcpParms.dhcpv4Enabled, //
+ "DHCPv4/UseDNSServers", v4dhcpParms.useDnsServers, //
+ "DHCPv4/UseDomainName", v4dhcpParms.useDomainName, //
+ "DHCPv4/UseNTPServers", v4dhcpParms.useNtpServers, //
+ "DHCPv6/OperatingMode",
+ v6dhcpParms.dhcpv6OperatingMode, //
+ "DHCPv6/UseDNSServers", v6dhcpParms.useDnsServers, //
+ "DHCPv6/UseDomainName", v6dhcpParms.useDomainName, //
+ "DHCPv6/UseNTPServers", v6dhcpParms.useNtpServers, //
+ "FQDN", fqdn, //
+ "HostName", hostname, //
+ "InterfaceEnabled", interfaceEnabled, //
+ "IPv4StaticAddresses", ipv4StaticAddresses, //
+ "IPv6DefaultGateway", ipv6DefaultGateway, //
+ "IPv6StaticAddresses", ipv6StaticAddresses, //
+ "IPv6StaticDefaultGateways",
+ ipv6StaticDefaultGateways, //
+ "InterfaceEnabled", interfaceEnabled, //
+ "MACAddress", macAddress, //
+ "MTUSize", mtuSize, //
+ "StatelessAddressAutoConfig/IPv6AutoConfigEnabled",
+ ipv6AutoConfigEnabled, //
+ "StaticNameServers", staticNameServers //
+ ))
+ {
+ return;
+ }
// Get single eth interface data, and call the below callback
// for JSON preparation
diff --git a/redfish-core/lib/event_service.hpp b/redfish-core/lib/event_service.hpp
index 60946b2..ca1e713 100644
--- a/redfish-core/lib/event_service.hpp
+++ b/redfish-core/lib/event_service.hpp
@@ -118,11 +118,12 @@
std::optional<bool> serviceEnabled;
std::optional<uint32_t> retryAttemps;
std::optional<uint32_t> retryInterval;
-
- if (!json_util::readJsonPatch(
- req, asyncResp->res, "ServiceEnabled", serviceEnabled,
- "DeliveryRetryAttempts", retryAttemps,
- "DeliveryRetryIntervalSeconds", retryInterval))
+ if (!json_util::readJsonPatch( //
+ req, asyncResp->res, //
+ "DeliveryRetryAttempts", retryAttemps, //
+ "DeliveryRetryIntervalSeconds", retryInterval, //
+ "ServiceEnabled", serviceEnabled //
+ ))
{
return;
}
@@ -302,23 +303,22 @@
std::optional<std::vector<nlohmann::json::object_t>> headers;
std::optional<std::vector<nlohmann::json::object_t>> mrdJsonArray;
- // clang-format off
- if (!json_util::readJsonPatch(
- req, asyncResp->res,
- "Context", context,
- "DeliveryRetryPolicy", retryPolicy,
- "Destination", destUrl,
- "EventFormatType", eventFormatType2,
- "HttpHeaders", headers,
- "MessageIds", msgIds,
- "MetricReportDefinitions", mrdJsonArray,
- "OriginResources", originResources,
- "Protocol", protocol,
- "RegistryPrefixes", regPrefixes,
- "ResourceTypes", resTypes,
- "SubscriptionType", subscriptionType,
- "VerifyCertificate", verifyCertificate
- ))
+ if (!json_util::readJsonPatch( //
+ req, asyncResp->res, //
+ "Context", context, //
+ "DeliveryRetryPolicy", retryPolicy, //
+ "Destination", destUrl, //
+ "EventFormatType", eventFormatType2, //
+ "HttpHeaders", headers, //
+ "MessageIds", msgIds, //
+ "MetricReportDefinitions", mrdJsonArray, //
+ "OriginResources", originResources, //
+ "Protocol", protocol, //
+ "RegistryPrefixes", regPrefixes, //
+ "ResourceTypes", resTypes, //
+ "SubscriptionType", subscriptionType, //
+ "VerifyCertificate", verifyCertificate //
+ ))
{
return;
}
@@ -755,11 +755,13 @@
std::optional<bool> verifyCertificate;
std::optional<std::vector<nlohmann::json::object_t>> headers;
- if (!json_util::readJsonPatch(
- req, asyncResp->res, "Context", context,
- "VerifyCertificate", verifyCertificate,
- "DeliveryRetryPolicy", retryPolicy, "HttpHeaders",
- headers))
+ if (!json_util::readJsonPatch( //
+ req, asyncResp->res, //
+ "Context", context, //
+ "DeliveryRetryPolicy", retryPolicy, //
+ "HttpHeaders", headers, //
+ "VerifyCertificate", verifyCertificate //
+ ))
{
return;
}
diff --git a/redfish-core/lib/hypervisor_system.hpp b/redfish-core/lib/hypervisor_system.hpp
index cc9d4c0..b05112f 100644
--- a/redfish-core/lib/hypervisor_system.hpp
+++ b/redfish-core/lib/hypervisor_system.hpp
@@ -543,9 +543,12 @@
std::string address;
std::string subnetMask;
std::string gateway;
- if (!json_util::readJsonObject(*obj, asyncResp->res, "Address", address,
- "SubnetMask", subnetMask, "Gateway",
- gateway))
+ if (!json_util::readJsonObject( //
+ *obj, asyncResp->res, //
+ "Address", address, //
+ "Gateway", gateway, //
+ "SubnetMask", subnetMask //
+ ))
{
return;
}
@@ -728,10 +731,13 @@
std::optional<std::vector<nlohmann::json::object_t>> ipv4Addresses;
std::optional<bool> ipv4DHCPEnabled;
- if (!json_util::readJsonPatch(
- req, asyncResp->res, "HostName", hostName, "IPv4StaticAddresses",
- ipv4StaticAddresses, "IPv4Addresses", ipv4Addresses,
- "DHCPv4/DHCPEnabled", ipv4DHCPEnabled))
+ if (!json_util::readJsonPatch( //
+ req, asyncResp->res, //
+ "DHCPv4/DHCPEnabled", ipv4DHCPEnabled, //
+ "IPv4Addresses", ipv4Addresses, //
+ "IPv4StaticAddresses", ipv4StaticAddresses, //
+ "HostName", hostName //
+ ))
{
return;
}
diff --git a/redfish-core/lib/log_services.hpp b/redfish-core/lib/log_services.hpp
index 639a314..73eb0b1 100644
--- a/redfish-core/lib/log_services.hpp
+++ b/redfish-core/lib/log_services.hpp
@@ -941,9 +941,11 @@
std::optional<std::string> diagnosticDataType;
std::optional<std::string> oemDiagnosticDataType;
- if (!redfish::json_util::readJsonAction(
- req, asyncResp->res, "DiagnosticDataType", diagnosticDataType,
- "OEMDiagnosticDataType", oemDiagnosticDataType))
+ if (!redfish::json_util::readJsonAction( //
+ req, asyncResp->res, //
+ "DiagnosticDataType", diagnosticDataType, //
+ "OEMDiagnosticDataType", oemDiagnosticDataType //
+ ))
{
return;
}
@@ -3055,10 +3057,11 @@
std::string diagnosticDataType;
std::string oemDiagnosticDataType;
- if (!redfish::json_util::readJsonAction(
- req, asyncResp->res, "DiagnosticDataType",
- diagnosticDataType, "OEMDiagnosticDataType",
- oemDiagnosticDataType))
+ if (!redfish::json_util::readJsonAction( //
+ req, asyncResp->res, //
+ "DiagnosticDataType", diagnosticDataType, //
+ "OEMDiagnosticDataType", oemDiagnosticDataType //
+ ))
{
return;
}
diff --git a/redfish-core/lib/managers.hpp b/redfish-core/lib/managers.hpp
index c4f9956..e20624e 100644
--- a/redfish-core/lib/managers.hpp
+++ b/redfish-core/lib/managers.hpp
@@ -213,9 +213,11 @@
std::optional<std::string> resetType;
std::optional<std::string> resetToDefaultsType;
- if (!json_util::readJsonAction(req, asyncResp->res, "ResetType",
- resetType, "ResetToDefaultsType",
- resetToDefaultsType))
+ if (!json_util::readJsonAction( //
+ req, asyncResp->res, //
+ "ResetToDefaultsType", resetToDefaultsType, //
+ "ResetType", resetType //
+ ))
{
BMCWEB_LOG_DEBUG("Missing property ResetType.");
@@ -968,22 +970,30 @@
std::optional<std::vector<std::string>> outputs;
std::map<std::string, std::optional<double>> doubles;
std::optional<std::string> setpointOffset;
- if (!redfish::json_util::readJson(
- jsonValue, response->res, "Inputs", inputs, "Outputs", outputs,
- "Zones", zones, "FFGainCoefficient",
- doubles["FFGainCoefficient"], "FFOffCoefficient",
- doubles["FFOffCoefficient"], "ICoefficient",
- doubles["ICoefficient"], "ILimitMax", doubles["ILimitMax"],
- "ILimitMin", doubles["ILimitMin"], "OutLimitMax",
- doubles["OutLimitMax"], "OutLimitMin", doubles["OutLimitMin"],
- "PCoefficient", doubles["PCoefficient"], "SetPoint",
- doubles["SetPoint"], "SetPointOffset", setpointOffset,
- "SlewNeg", doubles["SlewNeg"], "SlewPos", doubles["SlewPos"],
- "PositiveHysteresis", doubles["PositiveHysteresis"],
- "NegativeHysteresis", doubles["NegativeHysteresis"]))
+ if (!redfish::json_util::readJson( //
+ jsonValue, response->res, //
+ "FFGainCoefficient", doubles["FFGainCoefficient"], //
+ "FFOffCoefficient", doubles["FFOffCoefficient"], //
+ "ICoefficient", doubles["ICoefficient"], //
+ "ILimitMax", doubles["ILimitMax"], //
+ "ILimitMin", doubles["ILimitMin"], //
+ "Inputs", inputs, //
+ "NegativeHysteresis", doubles["NegativeHysteresis"], //
+ "OutLimitMax", doubles["OutLimitMax"], //
+ "OutLimitMin", doubles["OutLimitMin"], //
+ "Outputs", outputs, //
+ "PCoefficient", doubles["PCoefficient"], //
+ "PositiveHysteresis", doubles["PositiveHysteresis"], //
+ "SetPoint", doubles["SetPoint"], //
+ "SetPointOffset", setpointOffset, //
+ "SlewNeg", doubles["SlewNeg"], //
+ "SlewPos", doubles["SlewPos"], //
+ "Zones", zones //
+ ))
{
return CreatePIDRet::fail;
}
+
if (zones)
{
std::vector<std::string> zonesStr;
@@ -1069,10 +1079,11 @@
std::optional<std::string> chassisId;
std::optional<double> failSafePercent;
std::optional<double> minThermalOutput;
- if (!redfish::json_util::readJson(
- jsonValue, response->res, "Chassis/@odata.id", chassisId,
- "FailSafePercent", failSafePercent, "MinThermalOutput",
- minThermalOutput))
+ if (!redfish::json_util::readJson( //
+ jsonValue, response->res, //
+ "Chassis/@odata.id", chassisId, //
+ "FailSafePercent", failSafePercent, //
+ "MinThermalOutput", minThermalOutput))
{
return CreatePIDRet::fail;
}
@@ -1108,11 +1119,15 @@
std::optional<double> positiveHysteresis;
std::optional<double> negativeHysteresis;
std::optional<std::string> direction; // upper clipping curve vs lower
- if (!redfish::json_util::readJson(
- jsonValue, response->res, "Zones", zones, "Steps", steps,
- "Inputs", inputs, "PositiveHysteresis", positiveHysteresis,
- "NegativeHysteresis", negativeHysteresis, "Direction",
- direction))
+ if (!redfish::json_util::readJson( //
+ jsonValue, response->res, //
+ "Direction", direction, //
+ "Inputs", inputs, //
+ "NegativeHysteresis", negativeHysteresis, //
+ "PositiveHysteresis", positiveHysteresis, //
+ "Steps", steps, //
+ "Zones", zones //
+ ))
{
return CreatePIDRet::fail;
}
@@ -1145,8 +1160,11 @@
double target = 0.0;
double out = 0.0;
- if (!redfish::json_util::readJsonObject(
- step, response->res, "Target", target, "Output", out))
+ if (!redfish::json_util::readJsonObject( //
+ step, response->res, //
+ "Output", out, //
+ "Target", target //
+ ))
{
return CreatePIDRet::fail;
}
@@ -2325,20 +2343,21 @@
std::optional<nlohmann::json::object_t> stepwiseControllers;
std::optional<std::string> profile;
- // clang-format off
- if (!json_util::readJsonPatch(req, asyncResp->res,
- "DateTime", datetime,
- "Links/ActiveSoftwareImage/@odata.id", activeSoftwareImageOdataId,
- "Oem/OpenBmc/Fan/FanControllers", fanControllers,
- "Oem/OpenBmc/Fan/FanZones", fanZones,
- "Oem/OpenBmc/Fan/PidControllers", pidControllers,
- "Oem/OpenBmc/Fan/Profile", profile,
- "Oem/OpenBmc/Fan/StepwiseControllers", stepwiseControllers
- ))
- {
- return;
- }
- // clang-format on
+ if (!json_util::readJsonPatch( //
+ req, asyncResp->res, //
+ "DateTime", datetime, //
+ "Links/ActiveSoftwareImage/@odata.id",
+ activeSoftwareImageOdataId, //
+ "Oem/OpenBmc/Fan/FanControllers", fanControllers, //
+ "Oem/OpenBmc/Fan/FanZones", fanZones, //
+ "Oem/OpenBmc/Fan/PidControllers", pidControllers, //
+ "Oem/OpenBmc/Fan/Profile", profile, //
+ "Oem/OpenBmc/Fan/StepwiseControllers",
+ stepwiseControllers //
+ ))
+ {
+ return;
+ }
if (pidControllers || fanControllers || fanZones ||
stepwiseControllers || profile)
diff --git a/redfish-core/lib/metric_report_definition.hpp b/redfish-core/lib/metric_report_definition.hpp
index d92343d..c1fdb1c 100644
--- a/redfish-core/lib/metric_report_definition.hpp
+++ b/redfish-core/lib/metric_report_definition.hpp
@@ -437,10 +437,13 @@
std::optional<std::string> collectionFunction;
std::optional<std::string> collectionTimeScopeStr;
- if (!json_util::readJsonObject(
- metric, res, "MetricProperties", uris, "CollectionFunction",
- collectionFunction, "CollectionTimeScope", collectionTimeScopeStr,
- "CollectionDuration", collectionDurationStr))
+ if (!json_util::readJsonObject( //
+ metric, res, //
+ "CollectionDuration", collectionDurationStr, //
+ "CollectionFunction", collectionFunction, //
+ "CollectionTimeScope", collectionTimeScopeStr, //
+ "MetricProperties", uris //
+ ))
{
return false;
}
@@ -529,13 +532,18 @@
std::optional<std::vector<std::string>> reportActionsStr;
std::optional<std::string> scheduleDurationStr;
- if (!json_util::readJsonPatch(
- req, res, "Id", id, "Name", name, "Metrics", metrics,
- "MetricReportDefinitionType", reportingTypeStr, "ReportUpdates",
- reportUpdatesStr, "AppendLimit", appendLimit, "ReportActions",
- reportActionsStr, "Schedule/RecurrenceInterval",
- scheduleDurationStr, "MetricReportDefinitionEnabled",
- metricReportDefinitionEnabled))
+ if (!json_util::readJsonPatch( //
+ req, res, //
+ "AppendLimit", appendLimit, //
+ "Id", id, //
+ "MetricReportDefinitionEnabled", metricReportDefinitionEnabled, //
+ "MetricReportDefinitionType", reportingTypeStr, //
+ "Metrics", metrics, //
+ "Name", name, //
+ "ReportActions", reportActionsStr, //
+ "ReportUpdates", reportUpdatesStr, //
+ "Schedule/RecurrenceInterval", scheduleDurationStr //
+ ))
{
return false;
}
@@ -1328,12 +1336,15 @@
std::optional<std::vector<std::string>> reportActionsStr;
std::optional<std::string> scheduleDurationStr;
- if (!json_util::readJsonPatch(
- req, asyncResp->res, "Metrics", metrics,
- "MetricReportDefinitionType", reportingTypeStr, "ReportUpdates",
- reportUpdatesStr, "ReportActions", reportActionsStr,
- "Schedule/RecurrenceInterval", scheduleDurationStr,
- "MetricReportDefinitionEnabled", metricReportDefinitionEnabled))
+ if (!json_util::readJsonPatch( //
+ req, asyncResp->res, //
+ "MetricReportDefinitionEnabled", metricReportDefinitionEnabled, //
+ "MetricReportDefinitionType", reportingTypeStr, //
+ "Metrics", metrics, //
+ "ReportActions", reportActionsStr, //
+ "ReportUpdates", reportUpdatesStr, //
+ "Schedule/RecurrenceInterval", scheduleDurationStr //
+ ))
{
return;
}
diff --git a/redfish-core/lib/network_protocol.hpp b/redfish-core/lib/network_protocol.hpp
index f5b64f8..7868f98 100644
--- a/redfish-core/lib/network_protocol.hpp
+++ b/redfish-core/lib/network_protocol.hpp
@@ -507,18 +507,17 @@
std::optional<bool> ipmiEnabled;
std::optional<bool> sshEnabled;
- // clang-format off
- if (!json_util::readJsonPatch(
- req, asyncResp->res,
- "HostName", newHostName,
- "NTP/NTPServers", ntpServerObjects,
- "NTP/ProtocolEnabled", ntpEnabled,
- "IPMI/ProtocolEnabled", ipmiEnabled,
- "SSH/ProtocolEnabled", sshEnabled))
- {
- return;
- }
- // clang-format on
+ if (!json_util::readJsonPatch(
+ req, asyncResp->res, //
+ "HostName", newHostName, //
+ "NTP/NTPServers", ntpServerObjects, //
+ "NTP/ProtocolEnabled", ntpEnabled, //
+ "IPMI/ProtocolEnabled", ipmiEnabled, //
+ "SSH/ProtocolEnabled", sshEnabled //
+ ))
+ {
+ return;
+ }
asyncResp->res.result(boost::beast::http::status::no_content);
if (newHostName)
diff --git a/redfish-core/lib/power.hpp b/redfish-core/lib/power.hpp
index d284361..36a3b15 100644
--- a/redfish-core/lib/power.hpp
+++ b/redfish-core/lib/power.hpp
@@ -88,8 +88,10 @@
auto& item = powerControlCollections[0];
std::optional<uint32_t> value;
- if (!json_util::readJsonObject(item, sensorsAsyncResp->asyncResp->res,
- "PowerLimit/LimitInWatts", value))
+ if (!json_util::readJsonObject( //
+ item, sensorsAsyncResp->asyncResp->res, //
+ "PowerLimit/LimitInWatts", value //
+ ))
{
return;
}
@@ -305,9 +307,11 @@
std::optional<std::vector<nlohmann::json::object_t>> voltageCollections;
std::optional<std::vector<nlohmann::json::object_t>> powerCtlCollections;
- if (!json_util::readJsonPatch(req, sensorAsyncResp->asyncResp->res,
- "PowerControl", powerCtlCollections,
- "Voltages", voltageCollections))
+ if (!json_util::readJsonPatch( //
+ req, sensorAsyncResp->asyncResp->res, //
+ "PowerControl", powerCtlCollections, //
+ "Voltages", voltageCollections //
+ ))
{
return;
}
diff --git a/redfish-core/lib/processor.hpp b/redfish-core/lib/processor.hpp
index 82781d3..f753c13 100644
--- a/redfish-core/lib/processor.hpp
+++ b/redfish-core/lib/processor.hpp
@@ -1397,8 +1397,9 @@
std::optional<std::string> appliedConfigUri;
if (!json_util::readJsonPatch(
- req, asyncResp->res, "AppliedOperatingConfig/@odata.id",
- appliedConfigUri))
+ req, asyncResp->res, //
+ "AppliedOperatingConfig/@odata.id", appliedConfigUri //
+ ))
{
return;
}
diff --git a/redfish-core/lib/redfish_sessions.hpp b/redfish-core/lib/redfish_sessions.hpp
index 48d53bf..62e655f 100644
--- a/redfish-core/lib/redfish_sessions.hpp
+++ b/redfish-core/lib/redfish_sessions.hpp
@@ -213,9 +213,13 @@
std::string password;
std::optional<std::string> clientId;
std::optional<std::string> token;
- if (!json_util::readJsonPatch(req, asyncResp->res, "UserName", username,
- "Password", password, "Token", token,
- "Context", clientId))
+ if (!json_util::readJsonPatch( //
+ req, asyncResp->res, //
+ "Context", clientId, //
+ "Password", password, //
+ "Token", token, //
+ "UserName", username //
+ ))
{
return;
}
@@ -330,8 +334,10 @@
return;
}
std::optional<int64_t> sessionTimeout;
- if (!json_util::readJsonPatch(req, asyncResp->res, "SessionTimeout",
- sessionTimeout))
+ if (!json_util::readJsonPatch( //
+ req, asyncResp->res, //
+ "SessionTimeout", sessionTimeout //
+ ))
{
return;
}
diff --git a/redfish-core/lib/sensors.hpp b/redfish-core/lib/sensors.hpp
index f344220..697e3c5 100644
--- a/redfish-core/lib/sensors.hpp
+++ b/redfish-core/lib/sensors.hpp
@@ -2185,9 +2185,11 @@
}
for (auto& item : collectionItems.second)
{
- if (!json_util::readJsonObject(
- item, sensorAsyncResp->asyncResp->res, "MemberId", memberId,
- propertyValueName, value))
+ if (!json_util::readJsonObject( //
+ item, sensorAsyncResp->asyncResp->res, //
+ "MemberId", memberId, //
+ propertyValueName, value //
+ ))
{
return;
}
diff --git a/redfish-core/lib/systems.hpp b/redfish-core/lib/systems.hpp
index d9a8d17..5265436 100644
--- a/redfish-core/lib/systems.hpp
+++ b/redfish-core/lib/systems.hpp
@@ -3199,32 +3199,31 @@
std::optional<uint8_t> ipsExitUtil;
std::optional<uint64_t> ipsExitTime;
- // clang-format off
- if (!json_util::readJsonPatch(
- req, asyncResp->res,
- "IndicatorLED", indicatorLed,
- "LocationIndicatorActive", locationIndicatorActive,
- "AssetTag", assetTag,
- "PowerRestorePolicy", powerRestorePolicy,
- "PowerMode", powerMode,
- "HostWatchdogTimer/FunctionEnabled", wdtEnable,
- "HostWatchdogTimer/TimeoutAction", wdtTimeOutAction,
- "Boot/BootSourceOverrideTarget", bootSource,
- "Boot/BootSourceOverrideMode", bootType,
- "Boot/BootSourceOverrideEnabled", bootEnable,
- "Boot/AutomaticRetryConfig", bootAutomaticRetry,
- "Boot/AutomaticRetryAttempts", bootAutomaticRetryAttempts,
- "Boot/TrustedModuleRequiredToBoot", bootTrustedModuleRequired,
- "Boot/StopBootOnFault", stopBootOnFault,
- "IdlePowerSaver/Enabled", ipsEnable,
- "IdlePowerSaver/EnterUtilizationPercent", ipsEnterUtil,
- "IdlePowerSaver/EnterDwellTimeSeconds", ipsEnterTime,
- "IdlePowerSaver/ExitUtilizationPercent", ipsExitUtil,
- "IdlePowerSaver/ExitDwellTimeSeconds", ipsExitTime))
+ if (!json_util::readJsonPatch( //
+ req, asyncResp->res, //
+ "AssetTag", assetTag, //
+ "Boot/AutomaticRetryAttempts", bootAutomaticRetryAttempts, //
+ "Boot/AutomaticRetryConfig", bootAutomaticRetry, //
+ "Boot/BootSourceOverrideEnabled", bootEnable, //
+ "Boot/BootSourceOverrideMode", bootType, //
+ "Boot/BootSourceOverrideTarget", bootSource, //
+ "Boot/StopBootOnFault", stopBootOnFault, //
+ "Boot/TrustedModuleRequiredToBoot", bootTrustedModuleRequired, //
+ "HostWatchdogTimer/FunctionEnabled", wdtEnable, //
+ "HostWatchdogTimer/TimeoutAction", wdtTimeOutAction, //
+ "IdlePowerSaver/Enabled", ipsEnable, //
+ "IdlePowerSaver/EnterDwellTimeSeconds", ipsEnterTime, //
+ "IdlePowerSaver/EnterUtilizationPercent", ipsEnterUtil, //
+ "IdlePowerSaver/ExitDwellTimeSeconds", ipsExitTime, //
+ "IdlePowerSaver/ExitUtilizationPercent", ipsExitUtil, //
+ "IndicatorLED", indicatorLed, //
+ "LocationIndicatorActive", locationIndicatorActive, //
+ "PowerMode", powerMode, //
+ "PowerRestorePolicy", powerRestorePolicy //
+ ))
{
return;
}
- // clang-format on
asyncResp->res.result(boost::beast::http::status::no_content);
diff --git a/redfish-core/lib/thermal.hpp b/redfish-core/lib/thermal.hpp
index adcd4b9..b1b56a4 100644
--- a/redfish-core/lib/thermal.hpp
+++ b/redfish-core/lib/thermal.hpp
@@ -71,9 +71,11 @@
sensor_utils::chassisSubNodeToString(
sensor_utils::ChassisSubNode::thermalNode));
- if (!json_util::readJsonPatch(
- req, sensorsAsyncResp->asyncResp->res, "Temperatures",
- temperatureCollections, "Fans", fanCollections))
+ if (!json_util::readJsonPatch( //
+ req, sensorsAsyncResp->asyncResp->res, //
+ "Fans", fanCollections, //
+ "Temperatures", temperatureCollections //
+ ))
{
return;
}
diff --git a/redfish-core/lib/trigger.hpp b/redfish-core/lib/trigger.hpp
index d405d26..306742a 100644
--- a/redfish-core/lib/trigger.hpp
+++ b/redfish-core/lib/trigger.hpp
@@ -280,9 +280,12 @@
std::string activation;
std::string dwellTimeStr;
- if (!json_util::readJsonObject(threshold, res, "Reading", reading,
- "Activation", activation, "DwellTime",
- dwellTimeStr))
+ if (!json_util::readJsonObject( //
+ threshold, res, //
+ "Activation", activation, //
+ "DwellTime", dwellTimeStr, //
+ "Reading", reading //
+ ))
{
return false;
}
@@ -391,9 +394,13 @@
std::string dwellTimeStr;
std::string severity;
- if (!json_util::readJsonObject(thresholdInfo, res, "Name", name,
- "Value", value, "DwellTime",
- dwellTimeStr, "Severity", severity))
+ if (!json_util::readJsonObject( //
+ thresholdInfo, res, //
+ "DwellTime", dwellTimeStr, //
+ "Name", name, //
+ "Severity", severity, //
+ "Value", value //
+ ))
{
return false;
}
@@ -595,26 +602,25 @@
std::optional<std::vector<nlohmann::json::object_t>> discreteTriggers;
std::optional<std::vector<std::string>> metricReportDefinitions;
NumericThresholds thresholds;
- // clang-format off
- if (!json_util::readJsonPatch(
- req, res,
- "Id", id,
- "Name", name,
- "MetricType", metricType,
- "TriggerActions", triggerActions,
- "DiscreteTriggerCondition", discreteTriggerCondition,
- "DiscreteTriggers", discreteTriggers,
- "NumericThresholds/UpperCritical", thresholds.upperCritical,
- "NumericThresholds/UpperWarning", thresholds.upperWarning,
- "NumericThresholds/LowerWarning", thresholds.lowerWarning,
- "NumericThresholds/LowerCritical", thresholds.lowerCritical,
- "MetricProperties", ctx.metricProperties,
- "Links/MetricReportDefinitions", metricReportDefinitions)
- )
+
+ if (!json_util::readJsonPatch( //
+ req, res, //
+ "Id", id, //
+ "DiscreteTriggerCondition", discreteTriggerCondition, //
+ "DiscreteTriggers", discreteTriggers, //
+ "Links/MetricReportDefinitions", metricReportDefinitions, //
+ "MetricProperties", ctx.metricProperties, //
+ "MetricType", metricType, //
+ "Name", name, //
+ "NumericThresholds/LowerCritical", thresholds.lowerCritical, //
+ "NumericThresholds/LowerWarning", thresholds.lowerWarning, //
+ "NumericThresholds/UpperCritical", thresholds.upperCritical, //
+ "NumericThresholds/UpperWarning", thresholds.upperWarning, //
+ "TriggerActions", triggerActions //
+ ))
{
return false;
}
- // clang-format on
ctx.id = *id;
ctx.name = *name;
diff --git a/redfish-core/lib/update_service.hpp b/redfish-core/lib/update_service.hpp
index bf1a250..7c2c5f4 100644
--- a/redfish-core/lib/update_service.hpp
+++ b/redfish-core/lib/update_service.hpp
@@ -594,8 +594,11 @@
// 1) TransferProtocol:TFTP ImageURI:1.1.1.1/myfile.bin
// 2) ImageURI:tftp://1.1.1.1/myfile.bin
- if (!json_util::readJsonAction(req, asyncResp->res, "TransferProtocol",
- transferProtocol, "ImageURI", imageURI))
+ if (!json_util::readJsonAction( //
+ req, asyncResp->res, //
+ "ImageURI", imageURI, //
+ "TransferProtocol", transferProtocol //
+ ))
{
BMCWEB_LOG_DEBUG("Missing TransferProtocol or ImageURI parameter");
return;
@@ -766,9 +769,11 @@
return std::nullopt;
}
- if (!json_util::readJsonObject(
- *obj, asyncResp->res, "Targets", tempTargets,
- "@Redfish.OperationApplyTime", multiRet.applyTime))
+ if (!json_util::readJsonObject( //
+ *obj, asyncResp->res, //
+ "@Redfish.OperationApplyTime", multiRet.applyTime, //
+ "Targets", tempTargets //
+ ))
{
return std::nullopt;
}
diff --git a/redfish-core/lib/virtual_media.hpp b/redfish-core/lib/virtual_media.hpp
index a18f1d0..cd0d972 100644
--- a/redfish-core/lib/virtual_media.hpp
+++ b/redfish-core/lib/virtual_media.hpp
@@ -708,13 +708,16 @@
InsertMediaActionParams actionParams;
// Read obligatory parameters (url of image)
- if (!json_util::readJsonAction(
- req, asyncResp->res, "Image", actionParams.imageUrl,
- "WriteProtected", actionParams.writeProtected, "UserName",
- actionParams.userName, "Password", actionParams.password,
- "Inserted", actionParams.inserted, "TransferMethod",
- actionParams.transferMethod, "TransferProtocolType",
- actionParams.transferProtocolType))
+ if (!json_util::readJsonAction( //
+ req, asyncResp->res, //
+ "Image", actionParams.imageUrl, //
+ "Inserted", actionParams.inserted, //
+ "Password", actionParams.password, //
+ "TransferMethod", actionParams.transferMethod, //
+ "TransferProtocolType", actionParams.transferProtocolType, //
+ "UserName", actionParams.userName, //
+ "WriteProtected", actionParams.writeProtected //
+ ))
{
return;
}