CockpitAutomationTargetResource.fromJson constructor
CockpitAutomationTargetResource.fromJson(
- Object? value, {
- String path = r'$',
- CockpitDecodePolicy decodePolicy = CockpitDecodePolicy.requests,
Decodes a CockpitAutomationTargetResource from a JSON object.
Implementation
factory CockpitAutomationTargetResource.fromJson(
Object? value, {
String path = r'$',
CockpitDecodePolicy decodePolicy = CockpitDecodePolicy.requests,
}) {
final json = CockpitFoundationValueReader.object(value, path);
const fields = <String>{
'targetId',
'workspaceId',
'platform',
'deviceId',
'targetKind',
'mode',
'environment',
'entrypoint',
'entrypointSha256',
'flavor',
'appId',
'sessionId',
};
CockpitFoundationValueReader.keys(
json,
fields,
path,
required: const <String>{
'targetId',
'workspaceId',
'platform',
'deviceId',
'targetKind',
'mode',
'environment',
},
policy: decodePolicy,
);
return CockpitAutomationTargetResource(
targetId: CockpitFoundationValueReader.id(
json['targetId'],
'$path.targetId',
),
workspaceId: CockpitFoundationValueReader.id(
json['workspaceId'],
'$path.workspaceId',
),
platform: CockpitFoundationValueReader.string(
json['platform'],
'$path.platform',
maximum: 32,
),
deviceId: CockpitFoundationValueReader.string(
json['deviceId'],
'$path.deviceId',
maximum: 256,
),
targetKind: _enumValue(
json['targetKind'],
CockpitTargetKind.values,
'$path.targetKind',
),
mode: _enumValue(
json['mode'],
CockpitAutomationTargetMode.values,
'$path.mode',
),
environment: _enumValue(
json['environment'],
CockpitAutomationTargetEnvironment.values,
'$path.environment',
),
entrypoint: json['entrypoint'] == null
? null
: CockpitFoundationValueReader.relativePath(
json['entrypoint'],
'$path.entrypoint',
),
entrypointSha256: json['entrypointSha256'] == null
? null
: CockpitFoundationValueReader.sha256(
json['entrypointSha256'],
'$path.entrypointSha256',
),
flavor: CockpitFoundationValueReader.optionalString(
json['flavor'],
'$path.flavor',
maximum: 128,
),
appId: CockpitFoundationValueReader.optionalString(
json['appId'],
'$path.appId',
maximum: 512,
),
sessionId: json['sessionId'] == null
? null
: CockpitFoundationValueReader.id(
json['sessionId'],
'$path.sessionId',
),
);
}