import * as Models from './models'; import * as Parameters from './parameters'; import { Callback } from '../callback'; import { Client } from '../clients'; import { RequestConfig } from '../requestConfig'; export class IssueWorklogs { constructor(private client: Client) {} /** * Returns worklogs for an issue, starting from the oldest worklog or from the worklog started on or after a date and * time. * * Time tracking must be enabled in Jira, otherwise this operation returns an error. For more information, see * [Configuring time tracking](https://confluence.atlassian.com/x/qoXKM). * * This operation can be accessed anonymously. * * **[Permissions](https://developer.atlassian.com/cloud/jira/platform/rest/v3/intro/#permissions) required:** * Workloads are only returned where the user has: * * - _Browse projects_ [project permission](https://confluence.atlassian.com/x/yodKLg) for the project that the issue is * in. * - If [issue-level security](https://confluence.atlassian.com/x/J4lKLg) is configured, issue-level security permission * to view the issue. * - If the worklog has visibility restrictions, belongs to the group or has the role visibility is restricted to. */ async getIssueWorklog( parameters: Parameters.GetIssueWorklog, callback: Callback, ): Promise; /** * Returns worklogs for an issue, starting from the oldest worklog or from the worklog started on or after a date and * time. * * Time tracking must be enabled in Jira, otherwise this operation returns an error. For more information, see * [Configuring time tracking](https://confluence.atlassian.com/x/qoXKM). * * This operation can be accessed anonymously. * * **[Permissions](https://developer.atlassian.com/cloud/jira/platform/rest/v3/intro/#permissions) required:** * Workloads are only returned where the user has: * * - _Browse projects_ [project permission](https://confluence.atlassian.com/x/yodKLg) for the project that the issue is * in. * - If [issue-level security](https://confluence.atlassian.com/x/J4lKLg) is configured, issue-level security permission * to view the issue. * - If the worklog has visibility restrictions, belongs to the group or has the role visibility is restricted to. */ async getIssueWorklog( parameters: Parameters.GetIssueWorklog, callback?: never, ): Promise; async getIssueWorklog( parameters: Parameters.GetIssueWorklog, callback?: Callback, ): Promise { const config: RequestConfig = { url: `/rest/api/3/issue/${parameters.issueIdOrKey}/worklog`, method: 'GET', params: { startAt: parameters.startAt, maxResults: parameters.maxResults, startedAfter: parameters.startedAfter, startedBefore: parameters.startedBefore, expand: parameters.expand, }, }; return this.client.sendRequest(config, callback); } /** * Adds a worklog to an issue. * * Time tracking must be enabled in Jira, otherwise this operation returns an error. For more information, see * [Configuring time tracking](https://confluence.atlassian.com/x/qoXKM). * * This operation can be accessed anonymously. * * **[Permissions](https://developer.atlassian.com/cloud/jira/platform/rest/v3/intro/#permissions) required:** * * - _Browse projects_ and _Work on issues_ [project permission](https://confluence.atlassian.com/x/yodKLg) for the * project that the issue is in. * - If [issue-level security](https://confluence.atlassian.com/x/J4lKLg) is configured, issue-level security permission * to view the issue. */ async addWorklog(parameters: Parameters.AddWorklog, callback: Callback): Promise; /** * Adds a worklog to an issue. * * Time tracking must be enabled in Jira, otherwise this operation returns an error. For more information, see * [Configuring time tracking](https://confluence.atlassian.com/x/qoXKM). * * This operation can be accessed anonymously. * * **[Permissions](https://developer.atlassian.com/cloud/jira/platform/rest/v3/intro/#permissions) required:** * * - _Browse projects_ and _Work on issues_ [project permission](https://confluence.atlassian.com/x/yodKLg) for the * project that the issue is in. * - If [issue-level security](https://confluence.atlassian.com/x/J4lKLg) is configured, issue-level security permission * to view the issue. */ async addWorklog(parameters: Parameters.AddWorklog, callback?: never): Promise; async addWorklog(parameters: Parameters.AddWorklog, callback?: Callback): Promise { let comment: Models.Document | undefined; if (typeof parameters.comment === 'string') { comment = { type: 'doc', version: 1, content: [ { type: 'paragraph', content: [ { type: 'text', text: parameters.comment, }, ], }, ], }; } else { comment = parameters.comment; } const config: RequestConfig = { url: `/rest/api/3/issue/${parameters.issueIdOrKey}/worklog`, method: 'POST', params: { notifyUsers: parameters.notifyUsers, adjustEstimate: parameters.adjustEstimate, newEstimate: parameters.newEstimate, reduceBy: parameters.reduceBy, expand: parameters.expand, overrideEditableFlag: parameters.overrideEditableFlag, }, data: { self: parameters.self, author: parameters.author, updateAuthor: parameters.updateAuthor, comment, created: parameters.created, updated: parameters.updated, visibility: parameters.visibility, started: parameters.started, timeSpent: parameters.timeSpent, timeSpentSeconds: parameters.timeSpentSeconds, id: parameters.id, issueId: parameters.issueId, properties: parameters.properties, }, }; return this.client.sendRequest(config, callback); } /** * Returns a worklog. * * Time tracking must be enabled in Jira, otherwise this operation returns an error. For more information, see * [Configuring time tracking](https://confluence.atlassian.com/x/qoXKM). * * This operation can be accessed anonymously. * * **[Permissions](https://developer.atlassian.com/cloud/jira/platform/rest/v3/intro/#permissions) required:** * * - _Browse projects_ [project permission](https://confluence.atlassian.com/x/yodKLg) for the project that the issue is * in. * - If [issue-level security](https://confluence.atlassian.com/x/J4lKLg) is configured, issue-level security permission * to view the issue. * - If the worklog has visibility restrictions, belongs to the group or has the role visibility is restricted to. */ async getWorklog(parameters: Parameters.GetWorklog, callback: Callback): Promise; /** * Returns a worklog. * * Time tracking must be enabled in Jira, otherwise this operation returns an error. For more information, see * [Configuring time tracking](https://confluence.atlassian.com/x/qoXKM). * * This operation can be accessed anonymously. * * **[Permissions](https://developer.atlassian.com/cloud/jira/platform/rest/v3/intro/#permissions) required:** * * - _Browse projects_ [project permission](https://confluence.atlassian.com/x/yodKLg) for the project that the issue is * in. * - If [issue-level security](https://confluence.atlassian.com/x/J4lKLg) is configured, issue-level security permission * to view the issue. * - If the worklog has visibility restrictions, belongs to the group or has the role visibility is restricted to. */ async getWorklog(parameters: Parameters.GetWorklog, callback?: never): Promise; async getWorklog(parameters: Parameters.GetWorklog, callback?: Callback): Promise { const config: RequestConfig = { url: `/rest/api/3/issue/${parameters.issueIdOrKey}/worklog/${parameters.id}`, method: 'GET', params: { expand: parameters.expand, }, }; return this.client.sendRequest(config, callback); } /** * Updates a worklog. * * Time tracking must be enabled in Jira, otherwise this operation returns an error. For more information, see * [Configuring time tracking](https://confluence.atlassian.com/x/qoXKM). * * This operation can be accessed anonymously. * * **[Permissions](https://developer.atlassian.com/cloud/jira/platform/rest/v3/intro/#permissions) required:** * * - _Browse projects_ [project permission](https://confluence.atlassian.com/x/yodKLg) for the project that the issue is * in. * - If [issue-level security](https://confluence.atlassian.com/x/J4lKLg) is configured, issue-level security permission * to view the issue. * - _Edit all worklogs_[ project permission](https://confluence.atlassian.com/x/yodKLg) to update any worklog or _Edit * own worklogs_ to update worklogs created by the user. * - If the worklog has visibility restrictions, belongs to the group or has the role visibility is restricted to. */ async updateWorklog(parameters: Parameters.UpdateWorklog, callback: Callback): Promise; /** * Updates a worklog. * * Time tracking must be enabled in Jira, otherwise this operation returns an error. For more information, see * [Configuring time tracking](https://confluence.atlassian.com/x/qoXKM). * * This operation can be accessed anonymously. * * **[Permissions](https://developer.atlassian.com/cloud/jira/platform/rest/v3/intro/#permissions) required:** * * - _Browse projects_ [project permission](https://confluence.atlassian.com/x/yodKLg) for the project that the issue is * in. * - If [issue-level security](https://confluence.atlassian.com/x/J4lKLg) is configured, issue-level security permission * to view the issue. * - _Edit all worklogs_[ project permission](https://confluence.atlassian.com/x/yodKLg) to update any worklog or _Edit * own worklogs_ to update worklogs created by the user. * - If the worklog has visibility restrictions, belongs to the group or has the role visibility is restricted to. */ async updateWorklog(parameters: Parameters.UpdateWorklog, callback?: never): Promise; async updateWorklog( parameters: Parameters.UpdateWorklog, callback?: Callback, ): Promise { let comment: Models.Document | undefined; if (typeof parameters.comment === 'string') { comment = { type: 'doc', version: 1, content: [ { type: 'paragraph', content: [ { type: 'text', text: parameters.comment, }, ], }, ], }; } else { comment = parameters.comment; } const config: RequestConfig = { url: `/rest/api/3/issue/${parameters.issueIdOrKey}/worklog/${parameters.id}`, method: 'PUT', params: { notifyUsers: parameters.notifyUsers, adjustEstimate: parameters.adjustEstimate, newEstimate: parameters.newEstimate, expand: parameters.expand, overrideEditableFlag: parameters.overrideEditableFlag, }, data: { comment, visibility: parameters.visibility, started: parameters.started, timeSpent: parameters.timeSpent, timeSpentSeconds: parameters.timeSpentSeconds, properties: parameters.properties, }, }; return this.client.sendRequest(config, callback); } /** * Deletes a worklog from an issue. * * Time tracking must be enabled in Jira, otherwise this operation returns an error. For more information, see * [Configuring time tracking](https://confluence.atlassian.com/x/qoXKM). * * This operation can be accessed anonymously. * * **[Permissions](https://developer.atlassian.com/cloud/jira/platform/rest/v3/intro/#permissions) required:** * * - _Browse projects_ [project permission](https://confluence.atlassian.com/x/yodKLg) for the project that the issue is * in. * - If [issue-level security](https://confluence.atlassian.com/x/J4lKLg) is configured, issue-level security permission * to view the issue. * - _Delete all worklogs_[ project permission](https://confluence.atlassian.com/x/yodKLg) to delete any worklog or * _Delete own worklogs_ to delete worklogs created by the user, * - If the worklog has visibility restrictions, belongs to the group or has the role visibility is restricted to. */ async deleteWorklog(parameters: Parameters.DeleteWorklog, callback: Callback): Promise; /** * Deletes a worklog from an issue. * * Time tracking must be enabled in Jira, otherwise this operation returns an error. For more information, see * [Configuring time tracking](https://confluence.atlassian.com/x/qoXKM). * * This operation can be accessed anonymously. * * **[Permissions](https://developer.atlassian.com/cloud/jira/platform/rest/v3/intro/#permissions) required:** * * - _Browse projects_ [project permission](https://confluence.atlassian.com/x/yodKLg) for the project that the issue is * in. * - If [issue-level security](https://confluence.atlassian.com/x/J4lKLg) is configured, issue-level security permission * to view the issue. * - _Delete all worklogs_[ project permission](https://confluence.atlassian.com/x/yodKLg) to delete any worklog or * _Delete own worklogs_ to delete worklogs created by the user, * - If the worklog has visibility restrictions, belongs to the group or has the role visibility is restricted to. */ async deleteWorklog(parameters: Parameters.DeleteWorklog, callback?: never): Promise; async deleteWorklog(parameters: Parameters.DeleteWorklog, callback?: Callback): Promise { const config: RequestConfig = { url: `/rest/api/3/issue/${parameters.issueIdOrKey}/worklog/${parameters.id}`, method: 'DELETE', params: { notifyUsers: parameters.notifyUsers, adjustEstimate: parameters.adjustEstimate, newEstimate: parameters.newEstimate, increaseBy: parameters.increaseBy, overrideEditableFlag: parameters.overrideEditableFlag, }, }; return this.client.sendRequest(config, callback); } /** * Returns a list of IDs and delete timestamps for worklogs deleted after a date and time. * * This resource is paginated, with a limit of 1000 worklogs per page. Each page lists worklogs from oldest to * youngest. If the number of items in the date range exceeds 1000, `until` indicates the timestamp of the youngest * item on the page. Also, `nextPage` provides the URL for the next page of worklogs. The `lastPage` parameter is set * to true on the last page of worklogs. * * This resource does not return worklogs deleted during the minute preceding the request. * * **[Permissions](https://developer.atlassian.com/cloud/jira/platform/rest/v3/intro/#permissions) required:** * Permission to access Jira. */ async getIdsOfWorklogsDeletedSince( parameters: Parameters.GetIdsOfWorklogsDeletedSince | undefined, callback: Callback, ): Promise; /** * Returns a list of IDs and delete timestamps for worklogs deleted after a date and time. * * This resource is paginated, with a limit of 1000 worklogs per page. Each page lists worklogs from oldest to * youngest. If the number of items in the date range exceeds 1000, `until` indicates the timestamp of the youngest * item on the page. Also, `nextPage` provides the URL for the next page of worklogs. The `lastPage` parameter is set * to true on the last page of worklogs. * * This resource does not return worklogs deleted during the minute preceding the request. * * **[Permissions](https://developer.atlassian.com/cloud/jira/platform/rest/v3/intro/#permissions) required:** * Permission to access Jira. */ async getIdsOfWorklogsDeletedSince( parameters?: Parameters.GetIdsOfWorklogsDeletedSince, callback?: never, ): Promise; async getIdsOfWorklogsDeletedSince( parameters?: Parameters.GetIdsOfWorklogsDeletedSince, callback?: Callback, ): Promise { const config: RequestConfig = { url: '/rest/api/3/worklog/deleted', method: 'GET', params: { since: parameters?.since, }, }; return this.client.sendRequest(config, callback); } /** * Returns worklog details for a list of worklog IDs. * * The returned list of worklogs is limited to 1000 items. * * **[Permissions](https://developer.atlassian.com/cloud/jira/platform/rest/v3/intro/#permissions) required:** * Permission to access Jira, however, worklogs are only returned where either of the following is true: * * - The worklog is set as _Viewable by All Users_. * - The user is a member of a project role or group with permission to view the worklog. */ async getWorklogsForIds( parameters: Parameters.GetWorklogsForIds | undefined, callback: Callback, ): Promise; /** * Returns worklog details for a list of worklog IDs. * * The returned list of worklogs is limited to 1000 items. * * **[Permissions](https://developer.atlassian.com/cloud/jira/platform/rest/v3/intro/#permissions) required:** * Permission to access Jira, however, worklogs are only returned where either of the following is true: * * - The worklog is set as _Viewable by All Users_. * - The user is a member of a project role or group with permission to view the worklog. */ async getWorklogsForIds( parameters?: Parameters.GetWorklogsForIds, callback?: never, ): Promise; async getWorklogsForIds( parameters?: Parameters.GetWorklogsForIds, callback?: Callback, ): Promise { const config: RequestConfig = { url: '/rest/api/3/worklog/list', method: 'POST', params: { expand: parameters?.expand, }, data: { ids: parameters?.ids, }, }; return this.client.sendRequest(config, callback); } /** * Returns a list of IDs and update timestamps for worklogs updated after a date and time. * * This resource is paginated, with a limit of 1000 worklogs per page. Each page lists worklogs from oldest to * youngest. If the number of items in the date range exceeds 1000, `until` indicates the timestamp of the youngest * item on the page. Also, `nextPage` provides the URL for the next page of worklogs. The `lastPage` parameter is set * to true on the last page of worklogs. * * This resource does not return worklogs updated during the minute preceding the request. * * **[Permissions](https://developer.atlassian.com/cloud/jira/platform/rest/v3/intro/#permissions) required:** * Permission to access Jira, however, worklogs are only returned where either of the following is true: * * - The worklog is set as _Viewable by All Users_. * - The user is a member of a project role or group with permission to view the worklog. */ async getIdsOfWorklogsModifiedSince( parameters: Parameters.GetIdsOfWorklogsModifiedSince | undefined, callback: Callback, ): Promise; /** * Returns a list of IDs and update timestamps for worklogs updated after a date and time. * * This resource is paginated, with a limit of 1000 worklogs per page. Each page lists worklogs from oldest to * youngest. If the number of items in the date range exceeds 1000, `until` indicates the timestamp of the youngest * item on the page. Also, `nextPage` provides the URL for the next page of worklogs. The `lastPage` parameter is set * to true on the last page of worklogs. * * This resource does not return worklogs updated during the minute preceding the request. * * **[Permissions](https://developer.atlassian.com/cloud/jira/platform/rest/v3/intro/#permissions) required:** * Permission to access Jira, however, worklogs are only returned where either of the following is true: * * - The worklog is set as _Viewable by All Users_. * - The user is a member of a project role or group with permission to view the worklog. */ async getIdsOfWorklogsModifiedSince( parameters?: Parameters.GetIdsOfWorklogsModifiedSince, callback?: never, ): Promise; async getIdsOfWorklogsModifiedSince( parameters?: Parameters.GetIdsOfWorklogsModifiedSince, callback?: Callback, ): Promise { const config: RequestConfig = { url: '/rest/api/3/worklog/updated', method: 'GET', params: { since: parameters?.since, expand: parameters?.expand, }, }; return this.client.sendRequest(config, callback); } }