/*
 * Copyright (c) 2023-2025 Datalayer, Inc.
 * Distributed under the terms of the Modified BSD License.
 */
export const asUsage = (u) => {
    return {
        id: u.resource_uid,
        accountId: u.account_uid ?? '',
        type: u.resource_type,
        burningRate: u.burning_rate,
        creditsLimit: u.credits_limit,
        credits: u.credits,
        givenName: u.resource_given_name ?? u.resource_uid,
        startDate: new Date(u.start_date),
        updatedAt: new Date(u.updated_at),
        endDate: u.end_date ? new Date(u.end_date) : undefined,
        resourceState: u.resource_state,
        resources: u.pod_resources,
        metadata: new Map(Object.entries(u.metadata ?? {})),
    };
};
