export function getLabResourceName()

in tasks/Node/src/modules/task-utils/resourceutil.ts [54:71]


export function getLabResourceName(resourceId: string, resourceTypePlural: string): string {
    // Get all parts of the resource ID. This call will NOT affect casing, but it will remove
    // any trailing '/'.
    const parts = getIdParts(resourceId);

    // Determine if there's an error while parsing the resource ID.
    if (!parts || 6 > parts.length) {
        throw `ResourceUtil: Failed to parse string or too few resource type parts in lab resource ID '${resourceId}'.`;
    }

    // Ensure that the resource ID is that of a lab ("labs" is present where expected) or one
    // of it's child-resources. Also, do a sanity check that we have proper key/value pairs.
    if ('labs' !== parts[6].toLowerCase() || parts.length % 2 != 0) {
        throw `ResourceUtil: Invalid lab resource ID '${resourceId}'.`;
    }

    return getResourceName(resourceId, resourceTypePlural);
}