ModelContainerSpec.fromJson constructor

ModelContainerSpec.fromJson(
  1. Object? j
)

Implementation

factory ModelContainerSpec.fromJson(Object? j) {
  final json = j as Map<String, Object?>;
  return ModelContainerSpec(
    imageUri: switch (json['imageUri']) {
      null => '',
      Object $1 => decodeString($1),
    },
    command: switch (json['command']) {
      null => [],
      List<Object?> $1 => [for (final i in $1) decodeString(i)],
      _ => throw const FormatException('"command" is not a list'),
    },
    args: switch (json['args']) {
      null => [],
      List<Object?> $1 => [for (final i in $1) decodeString(i)],
      _ => throw const FormatException('"args" is not a list'),
    },
    env: switch (json['env']) {
      null => [],
      List<Object?> $1 => [for (final i in $1) EnvVar.fromJson(i)],
      _ => throw const FormatException('"env" is not a list'),
    },
    ports: switch (json['ports']) {
      null => [],
      List<Object?> $1 => [for (final i in $1) Port.fromJson(i)],
      _ => throw const FormatException('"ports" is not a list'),
    },
    predictRoute: switch (json['predictRoute']) {
      null => '',
      Object $1 => decodeString($1),
    },
    healthRoute: switch (json['healthRoute']) {
      null => '',
      Object $1 => decodeString($1),
    },
    invokeRoutePrefix: switch (json['invokeRoutePrefix']) {
      null => '',
      Object $1 => decodeString($1),
    },
    grpcPorts: switch (json['grpcPorts']) {
      null => [],
      List<Object?> $1 => [for (final i in $1) Port.fromJson(i)],
      _ => throw const FormatException('"grpcPorts" is not a list'),
    },
    deploymentTimeout: switch (json['deploymentTimeout']) {
      null => null,
      Object $1 => protobuf.Duration.fromJson($1),
    },
    sharedMemorySizeMb: switch (json['sharedMemorySizeMb']) {
      null => 0,
      Object $1 => decodeInt64($1),
    },
    startupProbe: switch (json['startupProbe']) {
      null => null,
      Object $1 => Probe.fromJson($1),
    },
    healthProbe: switch (json['healthProbe']) {
      null => null,
      Object $1 => Probe.fromJson($1),
    },
    livenessProbe: switch (json['livenessProbe']) {
      null => null,
      Object $1 => Probe.fromJson($1),
    },
  );
}