Edits history of script submission #3472 for ' Get project components (jira)'

  • nativets
    One script reply has been approved by the moderators
    Ap­pro­ved
    type Jira = {
      username: string;
      password: string;
      domain: string;
    };
    /**
     * Get project components
     * Returns all components in a project.
     */
    export async function main(
      auth: Jira,
      projectIdOrKey: string,
      componentSource: "jira" | "compass" | "auto" | undefined
    ) {
      const url = new URL(
        `https://${auth.domain}.atlassian.net/rest/api/2/project/${projectIdOrKey}/components`
      );
      for (const [k, v] of [["componentSource", componentSource]]) {
        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 components
     * Returns all components in a project.
     */
    export async function main(
      auth: Jira,
      projectIdOrKey: string,
      componentSource: "jira" | "compass" | "auto" | undefined
    ) {
      const url = new URL(
        `https://${auth.domain}.atlassian.net/rest/api/2/project/${projectIdOrKey}/components`
      );
      for (const [k, v] of [["componentSource", componentSource]]) {
        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 components
     * Returns all components in a project. See the [Get project components paginated](#api-rest-api-2-project-projectIdOrKey-component-get) resource if you want to get a full list of components with pagination.
    
    This operation can be accessed anonymously.
    
    **[Permissions](#permissions) required:** *Browse Projects* [project permission](https://confluence.atlassian.com/x/yodKLg) for the project.
     */
    export async function main(auth: Jira, projectIdOrKey: string) {
      const url = new URL(
        `https://${auth.domain}.atlassian.net/rest/api/2/project/${projectIdOrKey}/components`
      );
    
      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