InstanceProperties.fromJson constructor

InstanceProperties.fromJson(
  1. Object? j
)

Implementation

factory InstanceProperties.fromJson(Object? j) {
  final json = j as Map<String, Object?>;
  return InstanceProperties(
    advancedMachineFeatures: switch (json['advancedMachineFeatures']) {
      null => null,
      Object $1 => AdvancedMachineFeatures.fromJson($1),
    },
    canIpForward: switch (json['canIpForward']) {
      null => null,
      Object $1 => decodeBool($1),
    },
    confidentialInstanceConfig: switch (json['confidentialInstanceConfig']) {
      null => null,
      Object $1 => ConfidentialInstanceConfig.fromJson($1),
    },
    description: switch (json['description']) {
      null => null,
      Object $1 => decodeString($1),
    },
    disks: switch (json['disks']) {
      null => [],
      List<Object?> $1 => [for (final i in $1) AttachedDisk.fromJson(i)],
      _ => throw const FormatException('"disks" is not a list'),
    },
    guestAccelerators: switch (json['guestAccelerators']) {
      null => [],
      List<Object?> $1 => [for (final i in $1) AcceleratorConfig.fromJson(i)],
      _ => throw const FormatException('"guestAccelerators" is not a list'),
    },
    keyRevocationActionType: switch (json['keyRevocationActionType']) {
      null => null,
      Object $1 => decodeString($1),
    },
    labels: switch (json['labels']) {
      null => {},
      Map<String, Object?> $1 => {
        for (final e in $1.entries)
          decodeString(e.key): decodeString(e.value),
      },
      _ => throw const FormatException('"labels" is not an object'),
    },
    localSsdEncryptionMode: switch (json['localSsdEncryptionMode']) {
      null => null,
      Object $1 => decodeString($1),
    },
    machineType: switch (json['machineType']) {
      null => null,
      Object $1 => decodeString($1),
    },
    metadata: switch (json['metadata']) {
      null => null,
      Object $1 => Metadata.fromJson($1),
    },
    minCpuPlatform: switch (json['minCpuPlatform']) {
      null => null,
      Object $1 => decodeString($1),
    },
    networkInterfaces: switch (json['networkInterfaces']) {
      null => [],
      List<Object?> $1 => [for (final i in $1) NetworkInterface.fromJson(i)],
      _ => throw const FormatException('"networkInterfaces" is not a list'),
    },
    networkPerformanceConfig: switch (json['networkPerformanceConfig']) {
      null => null,
      Object $1 => NetworkPerformanceConfig.fromJson($1),
    },
    privateIpv6GoogleAccess: switch (json['privateIpv6GoogleAccess']) {
      null => null,
      Object $1 => decodeString($1),
    },
    reservationAffinity: switch (json['reservationAffinity']) {
      null => null,
      Object $1 => ReservationAffinity.fromJson($1),
    },
    resourceManagerTags: switch (json['resourceManagerTags']) {
      null => {},
      Map<String, Object?> $1 => {
        for (final e in $1.entries)
          decodeString(e.key): decodeString(e.value),
      },
      _ => throw const FormatException(
        '"resourceManagerTags" is not an object',
      ),
    },
    resourcePolicies: switch (json['resourcePolicies']) {
      null => [],
      List<Object?> $1 => [for (final i in $1) decodeString(i)],
      _ => throw const FormatException('"resourcePolicies" is not a list'),
    },
    scheduling: switch (json['scheduling']) {
      null => null,
      Object $1 => Scheduling.fromJson($1),
    },
    serviceAccounts: switch (json['serviceAccounts']) {
      null => [],
      List<Object?> $1 => [for (final i in $1) ServiceAccount.fromJson(i)],
      _ => throw const FormatException('"serviceAccounts" is not a list'),
    },
    shieldedInstanceConfig: switch (json['shieldedInstanceConfig']) {
      null => null,
      Object $1 => ShieldedInstanceConfig.fromJson($1),
    },
    tags: switch (json['tags']) {
      null => null,
      Object $1 => Tags.fromJson($1),
    },
    workloadIdentityConfig: switch (json['workloadIdentityConfig']) {
      null => null,
      Object $1 => WorkloadIdentityConfig.fromJson($1),
    },
  );
}