Edits history of script submission #944 for ' create resource (windmill)'

  • nativets
    One script reply has been approved by the moderators
    Ap­pro­ved
    /**
     * create resource
     *
     */
    export async function main(
      workspace: string,
      update_if_exists: string | undefined,
      body: {
        path: string;
        value: unknown;
        description?: string;
        resource_type: string;
        [k: string]: unknown;
      }
    ) {
      const url = new URL(`${BASE_URL}/api/w/${workspace}/resources/create`);
      for (const [k, v] of [["update_if_exists", update_if_exists]]) {
        if (v !== undefined && v !== "") {
          url.searchParams.append(k, v);
        }
      }
      const response = await fetch(url, {
        method: "POST",
        headers: {
          "Content-Type": "application/json",
          Authorization: "Bearer " + WM_TOKEN,
        },
        body: JSON.stringify(body),
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.text();
    }
    

    Submitted by hugo697 370 days ago

  • nativets
    /**
     * create resource
     *
     */
    export async function main(
      workspace: string,
      update_if_exists: string | undefined,
      body: {
        path: string;
        value: unknown;
        description?: string;
        resource_type: string;
        [k: string]: unknown;
      }
    ) {
      const url = new URL(`${BASE_URL}/api/w/${workspace}/resources/create`);
      for (const [k, v] of [["update_if_exists", update_if_exists]]) {
        if (v !== undefined && v !== "") {
          url.searchParams.append(k, v);
        }
      }
      const response = await fetch(url, {
        method: "POST",
        headers: {
          "Content-Type": "application/json",
          Authorization: "Bearer " + WM_TOKEN,
        },
        body: JSON.stringify(body),
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.text();
    }
    

    Submitted by hugo697 931 days ago

  • nativets
    /**
     * create resource
     *
     */
    export async function main(
      workspace: string,
      update_if_exists: string | undefined,
      body: {
        path: string;
        value: unknown;
        description?: string;
        resource_type: string;
        [k: string]: unknown;
      }
    ) {
      const url = new URL(`${BASE_URL}/api/w/${workspace}/resources/create`);
      for (const [k, v] of [["update_if_exists", update_if_exists]]) {
        if (v !== undefined) {
          url.searchParams.append(k, v);
        }
      }
      const response = await fetch(url, {
        method: "POST",
        headers: {
          "Content-Type": "application/json",
          Authorization: "Bearer " + WM_TOKEN,
        },
        body: JSON.stringify(body),
      });
      return await response.text();
    }
    

    Submitted by rubenfiszel 933 days ago

  • nativets
    /**
     * create resource
     *
     */
    export async function main(
      workspace: string,
      update_if_exists: string | undefined,
      body: {
        path: string;
        value: unknown;
        description?: string;
        resource_type: string;
        [k: string]: unknown;
      },
    ) {
      const url = new URL(`${BASE_URL}/api/w/${workspace}/resources/create`);
      for (const [k, v] of [["update_if_exists", update_if_exists]]) {
        if (v !== undefined) {
          url.searchParams.append(k, v);
        }
      }
      const response = await fetch(url, {
        method: "POST",
        headers: {
          "Content-Type": "application/json",
          Authorization: "Bearer " + WM_TOKEN,
        },
        body: JSON.stringify(body),
      });
      return await response.text();
    }
    

    Submitted by admin 1003 days ago