Commitment.fromJson constructor

Commitment.fromJson(
  1. Object? j
)

Implementation

factory Commitment.fromJson(Object? j) {
  final json = j as Map<String, Object?>;
  return Commitment(
    autoRenew: switch (json['autoRenew']) {
      null => null,
      Object $1 => decodeBool($1),
    },
    category: switch (json['category']) {
      null => null,
      Object $1 => decodeString($1),
    },
    creationTimestamp: switch (json['creationTimestamp']) {
      null => null,
      Object $1 => decodeString($1),
    },
    customEndTimestamp: switch (json['customEndTimestamp']) {
      null => null,
      Object $1 => decodeString($1),
    },
    description: switch (json['description']) {
      null => null,
      Object $1 => decodeString($1),
    },
    endTimestamp: switch (json['endTimestamp']) {
      null => null,
      Object $1 => decodeString($1),
    },
    existingReservations: switch (json['existingReservations']) {
      null => [],
      List<Object?> $1 => [for (final i in $1) decodeString(i)],
      _ => throw const FormatException(
        '"existingReservations" is not a list',
      ),
    },
    id: switch (json['id']) {
      null => null,
      Object $1 => decodeUint64($1),
    },
    kind: switch (json['kind']) {
      null => null,
      Object $1 => decodeString($1),
    },
    licenseResource: switch (json['licenseResource']) {
      null => null,
      Object $1 => LicenseResourceCommitment.fromJson($1),
    },
    mergeSourceCommitments: switch (json['mergeSourceCommitments']) {
      null => [],
      List<Object?> $1 => [for (final i in $1) decodeString(i)],
      _ => throw const FormatException(
        '"mergeSourceCommitments" is not a list',
      ),
    },
    name: switch (json['name']) {
      null => null,
      Object $1 => decodeString($1),
    },
    params: switch (json['params']) {
      null => null,
      Object $1 => CommitmentParams.fromJson($1),
    },
    plan: switch (json['plan']) {
      null => null,
      Object $1 => decodeString($1),
    },
    region: switch (json['region']) {
      null => null,
      Object $1 => decodeString($1),
    },
    reservations: switch (json['reservations']) {
      null => [],
      List<Object?> $1 => [for (final i in $1) Reservation.fromJson(i)],
      _ => throw const FormatException('"reservations" is not a list'),
    },
    resourceStatus: switch (json['resourceStatus']) {
      null => null,
      Object $1 => CommitmentResourceStatus.fromJson($1),
    },
    resources: switch (json['resources']) {
      null => [],
      List<Object?> $1 => [
        for (final i in $1) ResourceCommitment.fromJson(i),
      ],
      _ => throw const FormatException('"resources" is not a list'),
    },
    selfLink: switch (json['selfLink']) {
      null => null,
      Object $1 => decodeString($1),
    },
    splitSourceCommitment: switch (json['splitSourceCommitment']) {
      null => null,
      Object $1 => decodeString($1),
    },
    startTimestamp: switch (json['startTimestamp']) {
      null => null,
      Object $1 => decodeString($1),
    },
    status: switch (json['status']) {
      null => null,
      Object $1 => decodeString($1),
    },
    statusMessage: switch (json['statusMessage']) {
      null => null,
      Object $1 => decodeString($1),
    },
    type: switch (json['type']) {
      null => null,
      Object $1 => decodeString($1),
    },
  );
}