export type JTLPpsCoreContractsKeysResourceTypeKey = string; export type JTLDataContractsKeysWarenlagerKey = string; export type JTLPPSResourceManagementPublicApiDataTransferObjectsV2WorkbenchResourcesReservationMode = 0 | 1 | 2; export type JTLPPSResourceManagementPublicApiDataTransferObjectsV2WorkbenchResourcesExpiredComponentsUsage = 0 | 1; export type JTLPPSResourceManagementPublicApiDataTransferObjectsV2WorkbenchResourcesReplenishmentCreationAvailableStockReservationMode = 0 | 1 | 2; export type JTLPPSResourceManagementPublicApiDataTransferObjectsV2WorkbenchResourcesCreateWorkbenchResourceCommandRequest = {number?: string | undefined, name?: string | undefined, description?: string | undefined, workbenchResourceTypeId?: JTLPpsCoreContractsKeysResourceTypeKey | undefined, hostName?: string | undefined, warehouseId?: JTLDataContractsKeysWarenlagerKey | undefined, reservationMode?: JTLPPSResourceManagementPublicApiDataTransferObjectsV2WorkbenchResourcesReservationMode | undefined, autoShowProcessParameterValuesInProduction?: boolean | undefined, expiredComponentsUsage?: JTLPPSResourceManagementPublicApiDataTransferObjectsV2WorkbenchResourcesExpiredComponentsUsage | undefined, replenishmentCreationStockReservationMode?: JTLPPSResourceManagementPublicApiDataTransferObjectsV2WorkbenchResourcesReplenishmentCreationAvailableStockReservationMode | undefined}; export type CreateApiV2WorkbenchResourcesCreateArgs = {'x-tenant-id': string, 'x-runas'?: string | undefined, 'x-companyid'?: string | undefined, body: JTLPPSResourceManagementPublicApiDataTransferObjectsV2WorkbenchResourcesCreateWorkbenchResourceCommandRequest}; export type CreateApiV2WorkbenchResourcesCreateOptions = {baseUrl?: string | undefined, oauth2AuthorizationCode?: string | undefined, fetch?: typeof fetch | undefined}; /** * Creates a new workbench resource * * POST /v2/workbenchResources/create * * Also accepts auth: oauth2-client-credentials */ export const createApiV2WorkbenchResourcesCreate = async (args: CreateApiV2WorkbenchResourcesCreateArgs, options?: CreateApiV2WorkbenchResourcesCreateOptions) => { const {baseUrl = "https://scx-sbx.api.jtl-software.com", fetch: fetchFn = fetch, oauth2AuthorizationCode} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (args['x-tenant-id'] != null) headers.set("x-tenant-id", String(args['x-tenant-id'])) if (args['x-runas'] != null) headers.set("x-runas", String(args['x-runas'])) if (args['x-companyid'] != null) headers.set("x-companyid", String(args['x-companyid'])) if (oauth2AuthorizationCode !== undefined) headers.set('authorization', `Bearer ${oauth2AuthorizationCode}`) const url = `${baseUrl.replace(/\/+$/, '')}/v2/workbenchResources/create${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return (await res.json()) as unknown };