Edits history of script submission #3691 for ' Add share permission (jira)'

  • nativets
    One script reply has been approved by the moderators
    Ap­pro­ved
    type Jira = {
      username: string;
      password: string;
      domain: string;
    };
    /**
     * Add share permission
     * Add a share permissions to a filter. If you add a global share permission (one for all logged-in users or the public) it will overwrite all share permissions for the filter.
    
    Be aware that this operation uses different objects for updating share permissions compared to [Update filter](#api-rest-api-2-filter-id-put).
    
    **[Permissions](#permissions) required:** *Share dashboards and filters* [global permission](https://confluence.atlassian.com/x/x4dKLg) and the user must own the filter.
     */
    export async function main(
      auth: Jira,
      id: string,
      body: {
        accountId?: string;
        groupId?: string;
        groupname?: string;
        projectId?: string;
        projectRoleId?: string;
        rights?: number;
        type:
          | "user"
          | "project"
          | "group"
          | "projectRole"
          | "global"
          | "authenticated";
      }
    ) {
      const url = new URL(
        `https://${auth.domain}.atlassian.net/rest/api/2/filter/${id}/permission`
      );
    
      const response = await fetch(url, {
        method: "POST",
        headers: {
          "Content-Type": "application/json",
          Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
        },
        body: JSON.stringify(body),
      });
      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;
    };
    /**
     * Add share permission
     * Add a share permissions to a filter. If you add a global share permission (one for all logged-in users or the public) it will overwrite all share permissions for the filter.
    
    Be aware that this operation uses different objects for updating share permissions compared to [Update filter](#api-rest-api-2-filter-id-put).
    
    **[Permissions](#permissions) required:** *Share dashboards and filters* [global permission](https://confluence.atlassian.com/x/x4dKLg) and the user must own the filter.
     */
    export async function main(
      auth: Jira,
      id: string,
      body: {
        accountId?: string;
        groupId?: string;
        groupname?: string;
        projectId?: string;
        projectRoleId?: string;
        rights?: number;
        type:
          | "user"
          | "project"
          | "group"
          | "projectRole"
          | "global"
          | "authenticated";
      }
    ) {
      const url = new URL(
        `https://${auth.domain}.atlassian.net/rest/api/2/filter/${id}/permission`
      );
    
      const response = await fetch(url, {
        method: "POST",
        headers: {
          "Content-Type": "application/json",
          Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
        },
        body: JSON.stringify(body),
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.json();
    }
    

    Submitted by hugo697 948 days ago