fromJson static method
Returns a new PolicyAttributes instance and imports its values from
value
if it's a Map, null otherwise.
Implementation
// ignore: prefer_constructors_over_static_methods
static PolicyAttributes? fromJson(dynamic value) {
if (value is Map) {
final json = value.cast<String, dynamic>();
// Ensure that the map contains the required keys.
// Note 1: the values aren't checked for validity beyond being non-null.
// Note 2: this code is stripped in release mode!
assert(() {
requiredKeys.forEach((key) {
assert(json.containsKey(key), 'Required key "PolicyAttributes[$key]" is missing from JSON.');
assert(json[key] != null, 'Required key "PolicyAttributes[$key]" has a null value in JSON.');
});
return true;
}());
return PolicyAttributes(
name: mapValueOfType<String>(json, r'name')!,
duration: mapValueOfType<int>(json, r'duration'),
strict: mapValueOfType<bool>(json, r'strict')!,
floating: mapValueOfType<bool>(json, r'floating')!,
scheme: PolicyAttributesSchemeEnum.fromJson(json[r'scheme']),
requireProductScope: mapValueOfType<bool>(json, r'requireProductScope')!,
requirePolicyScope: mapValueOfType<bool>(json, r'requirePolicyScope')!,
requireMachineScope: mapValueOfType<bool>(json, r'requireMachineScope')!,
requireFingerprintScope: mapValueOfType<bool>(json, r'requireFingerprintScope')!,
requireUserScope: mapValueOfType<bool>(json, r'requireUserScope')!,
requireChecksumScope: mapValueOfType<bool>(json, r'requireChecksumScope')!,
requireVersionScope: mapValueOfType<bool>(json, r'requireVersionScope')!,
requireCheckIn: mapValueOfType<bool>(json, r'requireCheckIn')!,
checkInInterval: PolicyAttributesCheckInIntervalEnum.fromJson(json[r'checkInInterval']),
checkInIntervalCount: mapValueOfType<int>(json, r'checkInIntervalCount'),
usePool: mapValueOfType<bool>(json, r'usePool')!,
maxMachines: mapValueOfType<int>(json, r'maxMachines'),
maxProcesses: mapValueOfType<int>(json, r'maxProcesses'),
maxCores: mapValueOfType<int>(json, r'maxCores'),
maxUses: mapValueOfType<int>(json, r'maxUses'),
protected: mapValueOfType<bool>(json, r'protected')!,
requireHeartbeat: mapValueOfType<bool>(json, r'requireHeartbeat')!,
heartbeatDuration: mapValueOfType<int>(json, r'heartbeatDuration'),
heartbeatCullStrategy: PolicyAttributesHeartbeatCullStrategyEnum.fromJson(json[r'heartbeatCullStrategy'])!,
heartbeatResurrectionStrategy: PolicyAttributesHeartbeatResurrectionStrategyEnum.fromJson(json[r'heartbeatResurrectionStrategy'])!,
heartbeatBasis: PolicyAttributesHeartbeatBasisEnum.fromJson(json[r'heartbeatBasis'])!,
machineUniquenessStrategy: PolicyAttributesMachineUniquenessStrategyEnum.fromJson(json[r'machineUniquenessStrategy'])!,
machineMatchingStrategy: PolicyAttributesMachineMatchingStrategyEnum.fromJson(json[r'machineMatchingStrategy'])!,
expirationStrategy: PolicyAttributesExpirationStrategyEnum.fromJson(json[r'expirationStrategy'])!,
transferStrategy: PolicyAttributesTransferStrategyEnum.fromJson(json[r'transferStrategy'])!,
authenticationStrategy: PolicyAttributesAuthenticationStrategyEnum.fromJson(json[r'authenticationStrategy'])!,
machineLeasingStrategy: PolicyAttributesMachineLeasingStrategyEnum.fromJson(json[r'machineLeasingStrategy'])!,
processLeasingStrategy: PolicyAttributesProcessLeasingStrategyEnum.fromJson(json[r'processLeasingStrategy'])!,
overageStrategy: PolicyAttributesOverageStrategyEnum.fromJson(json[r'overageStrategy'])!,
metadata: mapCastOfType<String, Object>(json, r'metadata')!,
created: mapDateTime(json, r'created', r'')!,
updated: mapDateTime(json, r'updated', r'')!,
);
}
return null;
}