Edits history of script submission #3516 for ' Classic update workflow scheme (jira)'

  • nativets
    One script reply has been approved by the moderators
    Ap­pro­ved
    type Jira = {
      username: string;
      password: string;
      domain: string;
    };
    /**
     * Classic update workflow scheme
     * Updates a company-manged project workflow scheme, including the name, default workflow, issue type to project mappings, and more. If the workflow scheme is active (that is, being used by at least one project), then a draft workflow scheme is created or updated instead, provided that `updateDraftIfNeeded` is set to `true`.
    
    **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).
     */
    export async function main(
      auth: Jira,
      id: string,
      body: {
        defaultWorkflow?: string;
        description?: string;
        draft?: boolean;
        id?: number;
        issueTypeMappings?: { [k: string]: string };
        issueTypes?: {
          [k: string]: {
            avatarId?: number;
            description?: string;
            entityId?: string;
            hierarchyLevel?: number;
            iconUrl?: string;
            id?: string;
            name?: string;
            scope?: {
              project?: {
                avatarUrls?: {
                  "16x16"?: string;
                  "24x24"?: string;
                  "32x32"?: string;
                  "48x48"?: string;
                };
                id?: string;
                key?: string;
                name?: string;
                projectCategory?: {
                  description?: string;
                  id?: string;
                  name?: string;
                  self?: string;
                };
                projectTypeKey?: "software" | "service_desk" | "business";
                self?: string;
                simplified?: boolean;
              };
              type?: "PROJECT" | "TEMPLATE";
              [k: string]: unknown;
            };
            self?: string;
            subtask?: boolean;
          };
        };
        lastModified?: string;
        lastModifiedUser?: {
          accountId?: string;
          accountType?: "atlassian" | "app" | "customer" | "unknown";
          active?: boolean;
          applicationRoles?: {
            callback?: {};
            items?: {
              defaultGroups?: string[];
              defaultGroupsDetails?: {
                groupId?: string;
                name?: string;
                self?: string;
              }[];
              defined?: boolean;
              groupDetails?: { groupId?: string; name?: string; self?: string }[];
              groups?: string[];
              hasUnlimitedSeats?: boolean;
              key?: string;
              name?: string;
              numberOfSeats?: number;
              platform?: boolean;
              remainingSeats?: number;
              selectedByDefault?: boolean;
              userCount?: number;
              userCountDescription?: string;
            }[];
            "max-results"?: number;
            pagingCallback?: {};
            size?: number;
          };
          avatarUrls?: {
            "16x16"?: string;
            "24x24"?: string;
            "32x32"?: string;
            "48x48"?: string;
          };
          displayName?: string;
          emailAddress?: string;
          expand?: string;
          groups?: {
            callback?: {};
            items?: { groupId?: string; name?: string; self?: string }[];
            "max-results"?: number;
            pagingCallback?: {};
            size?: number;
          };
          key?: string;
          locale?: string;
          name?: string;
          self?: string;
          timeZone?: string;
        };
        name?: string;
        originalDefaultWorkflow?: string;
        originalIssueTypeMappings?: { [k: string]: string };
        self?: string;
        updateDraftIfNeeded?: boolean;
      }
    ) {
      const url = new URL(
        `https://${auth.domain}.atlassian.net/rest/api/2/workflowscheme/${id}`
      );
    
      const response = await fetch(url, {
        method: "PUT",
        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;
    };
    /**
     * Classic update workflow scheme
     * Updates a company-manged project workflow scheme, including the name, default workflow, issue type to project mappings, and more. If the workflow scheme is active (that is, being used by at least one project), then a draft workflow scheme is created or updated instead, provided that `updateDraftIfNeeded` is set to `true`.
    
    **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).
     */
    export async function main(
      auth: Jira,
      id: string,
      body: {
        defaultWorkflow?: string;
        description?: string;
        draft?: boolean;
        id?: number;
        issueTypeMappings?: { [k: string]: string };
        issueTypes?: {
          [k: string]: {
            avatarId?: number;
            description?: string;
            entityId?: string;
            hierarchyLevel?: number;
            iconUrl?: string;
            id?: string;
            name?: string;
            scope?: {
              project?: {
                avatarUrls?: {
                  "16x16"?: string;
                  "24x24"?: string;
                  "32x32"?: string;
                  "48x48"?: string;
                };
                id?: string;
                key?: string;
                name?: string;
                projectCategory?: {
                  description?: string;
                  id?: string;
                  name?: string;
                  self?: string;
                };
                projectTypeKey?: "software" | "service_desk" | "business";
                self?: string;
                simplified?: boolean;
              };
              type?: "PROJECT" | "TEMPLATE";
              [k: string]: unknown;
            };
            self?: string;
            subtask?: boolean;
          };
        };
        lastModified?: string;
        lastModifiedUser?: {
          accountId?: string;
          accountType?: "atlassian" | "app" | "customer" | "unknown";
          active?: boolean;
          applicationRoles?: {
            callback?: {};
            items?: {
              defaultGroups?: string[];
              defaultGroupsDetails?: {
                groupId?: string;
                name?: string;
                self?: string;
              }[];
              defined?: boolean;
              groupDetails?: { groupId?: string; name?: string; self?: string }[];
              groups?: string[];
              hasUnlimitedSeats?: boolean;
              key?: string;
              name?: string;
              numberOfSeats?: number;
              platform?: boolean;
              remainingSeats?: number;
              selectedByDefault?: boolean;
              userCount?: number;
              userCountDescription?: string;
            }[];
            "max-results"?: number;
            pagingCallback?: {};
            size?: number;
          };
          avatarUrls?: {
            "16x16"?: string;
            "24x24"?: string;
            "32x32"?: string;
            "48x48"?: string;
          };
          displayName?: string;
          emailAddress?: string;
          expand?: string;
          groups?: {
            callback?: {};
            items?: { groupId?: string; name?: string; self?: string }[];
            "max-results"?: number;
            pagingCallback?: {};
            size?: number;
          };
          key?: string;
          locale?: string;
          name?: string;
          self?: string;
          timeZone?: string;
        };
        name?: string;
        originalDefaultWorkflow?: string;
        originalIssueTypeMappings?: { [k: string]: string };
        self?: string;
        updateDraftIfNeeded?: boolean;
      }
    ) {
      const url = new URL(
        `https://${auth.domain}.atlassian.net/rest/api/2/workflowscheme/${id}`
      );
    
      const response = await fetch(url, {
        method: "PUT",
        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