import { setItemAccess, updateGroup } from "@esri/arcgis-rest-portal";
import { getTypeFromEntity } from "./getTypeFromEntity";
import { updateEvent } from "../events/api/events";
/**
 * Sets an entity's access to the given access
 * @param entity A HubEntity object
 * @param access The access to set the entity to
 * @param context An IArcGISContext object
 * @returns a promise
 */
export async function setEntityAccess(entity, access, context) {
    const type = getTypeFromEntity(entity);
    switch (type) {
        case "event":
            await updateEvent(Object.assign({ eventId: entity.id, data: {
                    access: access.toUpperCase(),
                } }, context.hubRequestOptions));
            break;
        case "group":
            await updateGroup({
                group: {
                    id: entity.id,
                    access,
                },
                authentication: context.session,
            });
            break;
        default:
            await setItemAccess({
                id: entity.id,
                access,
                owner: entity.owner,
                authentication: context.session,
            });
            break;
    }
}
//# sourceMappingURL=setEntityAccess.js.map