Edits history of script submission #3720 for ' Get project role details (jira)'

  • nativets
    One script reply has been approved by the moderators
    Ap­pro­ved
    type Jira = {
      username: string;
      password: string;
      domain: string;
    };
    /**
     * Get project role details
     * Returns all [project roles](https://support.atlassian.com/jira-cloud-administration/docs/manage-project-roles/) and the details for each role. Note that the list of project roles is common to all projects.
    
    This operation can be accessed anonymously.
    
    **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg) or *Administer projects* [project permission](https://confluence.atlassian.com/x/yodKLg) for the project.
     */
    export async function main(
      auth: Jira,
      projectIdOrKey: string,
      currentMember: string | undefined,
      excludeConnectAddons: string | undefined
    ) {
      const url = new URL(
        `https://${auth.domain}.atlassian.net/rest/api/2/project/${projectIdOrKey}/roledetails`
      );
      for (const [k, v] of [
        ["currentMember", currentMember],
        ["excludeConnectAddons", excludeConnectAddons],
      ]) {
        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 project role details
     * Returns all [project roles](https://support.atlassian.com/jira-cloud-administration/docs/manage-project-roles/) and the details for each role. Note that the list of project roles is common to all projects.
    
    This operation can be accessed anonymously.
    
    **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg) or *Administer projects* [project permission](https://confluence.atlassian.com/x/yodKLg) for the project.
     */
    export async function main(
      auth: Jira,
      projectIdOrKey: string,
      currentMember: string | undefined,
      excludeConnectAddons: string | undefined
    ) {
      const url = new URL(
        `https://${auth.domain}.atlassian.net/rest/api/2/project/${projectIdOrKey}/roledetails`
      );
      for (const [k, v] of [
        ["currentMember", currentMember],
        ["excludeConnectAddons", excludeConnectAddons],
      ]) {
        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 823 days ago

  • nativets
    type Jira = {
      username: string;
      password: string;
      domain: string;
    };
    /**
     * Get project role details
     * Returns all [project roles](https://confluence.atlassian.com/x/3odKLg) and the details for each role. Note that the list of project roles is common to all projects.
    
    This operation can be accessed anonymously.
    
    **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg) or *Administer projects* [project permission](https://confluence.atlassian.com/x/yodKLg) for the project.
     */
    export async function main(
      auth: Jira,
      projectIdOrKey: string,
      currentMember: string | undefined,
      excludeConnectAddons: string | undefined
    ) {
      const url = new URL(
        `https://${auth.domain}.atlassian.net/rest/api/2/project/${projectIdOrKey}/roledetails`
      );
      for (const [k, v] of [
        ["currentMember", currentMember],
        ["excludeConnectAddons", excludeConnectAddons],
      ]) {
        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