Edits history of script submission #3463 for ' Get filter (jira)'

  • nativets
    One script reply has been approved by the moderators
    Ap­pro­ved
    type Jira = {
      username: string;
      password: string;
      domain: string;
    };
    /**
     * Get filter
     * Returns a filter.
    
    This operation can be accessed anonymously.
    
    **[Permissions](#permissions) required:** None, however, the filter is only returned where it is:
    
     *  owned by the user.
     *  shared with a group that the user is a member of.
     *  shared with a private project that the user has *Browse projects* [project permission](https://confluence.atlassian.com/x/yodKLg) for.
     *  shared with a public project.
     *  shared with the public.
     */
    export async function main(
      auth: Jira,
      id: string,
      expand: string | undefined,
      overrideSharePermissions: string | undefined
    ) {
      const url = new URL(
        `https://${auth.domain}.atlassian.net/rest/api/2/filter/${id}`
      );
      for (const [k, v] of [
        ["expand", expand],
        ["overrideSharePermissions", overrideSharePermissions],
      ]) {
        if (v !== undefined && v !== "") {
          url.searchParams.append(k, v);
        }
      }
      const response = await fetch(url, {
        method: "GET",
        headers: {
          Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
        },
        body: undefined,
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.json();
    }
    

    Submitted by hugo697 396 days ago

  • nativets
    type Jira = {
      username: string;
      password: string;
      domain: string;
    };
    /**
     * Get filter
     * Returns a filter.
    
    This operation can be accessed anonymously.
    
    **[Permissions](#permissions) required:** None, however, the filter is only returned where it is:
    
     *  owned by the user.
     *  shared with a group that the user is a member of.
     *  shared with a private project that the user has *Browse projects* [project permission](https://confluence.atlassian.com/x/yodKLg) for.
     *  shared with a public project.
     *  shared with the public.
     */
    export async function main(
      auth: Jira,
      id: string,
      expand: string | undefined,
      overrideSharePermissions: string | undefined
    ) {
      const url = new URL(
        `https://${auth.domain}.atlassian.net/rest/api/2/filter/${id}`
      );
      for (const [k, v] of [
        ["expand", expand],
        ["overrideSharePermissions", overrideSharePermissions],
      ]) {
        if (v !== undefined && v !== "") {
          url.searchParams.append(k, v);
        }
      }
      const response = await fetch(url, {
        method: "GET",
        headers: {
          Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
        },
        body: undefined,
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.json();
    }
    

    Submitted by hugo697 948 days ago