export type SasPortalCreateSignedDeviceRequest = {installerId?: string | undefined, encodedDevice?: string | undefined}; export type CreateApiV1alpha1ParentDevicesCreateSignedArgs = {parent: string, body: SasPortalCreateSignedDeviceRequest}; export type CreateApiV1alpha1ParentDevicesCreateSignedOptions = {baseUrl?: string | undefined, Oauth2?: string | undefined, Oauth2c?: string | undefined, fetch?: typeof fetch | undefined}; /** * Creates a signed device under a node or customer. * * POST /v1alpha1/{+parent}/devices:createSigned * * Also accepts auth: Oauth2 + Oauth2c */ export const createApiV1alpha1ParentDevicesCreateSigned = async (args: CreateApiV1alpha1ParentDevicesCreateSignedArgs, options?: CreateApiV1alpha1ParentDevicesCreateSignedOptions) => { const {baseUrl = "https://prod-tt-sasportal.googleapis.com", fetch: fetchFn = fetch, Oauth2, Oauth2c} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "*/*") if (Oauth2 !== undefined) headers.set('authorization', `Bearer ${Oauth2}`) if (Oauth2c !== undefined) headers.set('authorization', `Bearer ${Oauth2c}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1alpha1/${encodeURIComponent(String(args['+parent']))}/devices:createSigned${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 res.blob() };