Edits history of script submission #3804 for ' Find groups (jira)'

  • nativets
    One script reply has been approved by the moderators
    Ap­pro­ved
    type Jira = {
      username: string;
      password: string;
      domain: string;
    };
    /**
     * Find groups
     * Returns a list of groups whose names contain a query string.
     */
    export async function main(
      auth: Jira,
      accountId: string | undefined,
      query: string | undefined,
      exclude: string | undefined,
      excludeId: string | undefined,
      maxResults: string | undefined,
      caseInsensitive: string | undefined,
      userName: string | undefined
    ) {
      const url = new URL(
        `https://${auth.domain}.atlassian.net/rest/api/2/groups/picker`
      );
      for (const [k, v] of [
        ["accountId", accountId],
        ["query", query],
        ["exclude", exclude],
        ["excludeId", excludeId],
        ["maxResults", maxResults],
        ["caseInsensitive", caseInsensitive],
        ["userName", userName],
      ]) {
        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;
    };
    /**
     * Find groups
     * Returns a list of groups whose names contain a query string.
     */
    export async function main(
      auth: Jira,
      accountId: string | undefined,
      query: string | undefined,
      exclude: string | undefined,
      excludeId: string | undefined,
      maxResults: string | undefined,
      caseInsensitive: string | undefined,
      userName: string | undefined
    ) {
      const url = new URL(
        `https://${auth.domain}.atlassian.net/rest/api/2/groups/picker`
      );
      for (const [k, v] of [
        ["accountId", accountId],
        ["query", query],
        ["exclude", exclude],
        ["excludeId", excludeId],
        ["maxResults", maxResults],
        ["caseInsensitive", caseInsensitive],
        ["userName", userName],
      ]) {
        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