Skip to content

Add new API in Version2Client #357

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Mar 1, 2025
Prev Previous commit
Next Next commit
Fixes
  • Loading branch information
MrRefactoring committed Feb 23, 2025
commit f340a3b6b81444933d8f4733c53b636d0311cd1a
1 change: 1 addition & 0 deletions src/version2/classificationLevels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { RequestConfig } from '../requestConfig';

export class ClassificationLevels {
constructor(private client: Client) {}

/**
* Returns all classification levels.
*
Expand Down
106 changes: 71 additions & 35 deletions src/version2/dashboards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { RequestConfig } from '../requestConfig';

export class Dashboards {
constructor(private client: Client) {}

/**
* Returns a list of dashboards owned by or shared with the user. The list may be filtered to include only favorite or
* owned dashboards.
Expand Down Expand Up @@ -46,41 +47,43 @@ export class Dashboards {

return this.client.sendRequest(config, callback);
}

/**
* Creates a dashboard.
*
* **[Permissions](https://developer.atlassian.com/cloud/jira/platform/rest/v2/intro/#permissions) required:** None.
*/
async createDashboard<T = Models.Dashboard>(
parameters: Parameters.CreateDashboard | undefined,
parameters: Parameters.CreateDashboard,
callback: Callback<T>,
): Promise<void>;
/**
* Creates a dashboard.
*
* **[Permissions](https://developer.atlassian.com/cloud/jira/platform/rest/v2/intro/#permissions) required:** None.
*/
async createDashboard<T = Models.Dashboard>(parameters?: Parameters.CreateDashboard, callback?: never): Promise<T>;
async createDashboard<T = Models.Dashboard>(parameters: Parameters.CreateDashboard, callback?: never): Promise<T>;
async createDashboard<T = Models.Dashboard>(
parameters?: Parameters.CreateDashboard,
parameters: Parameters.CreateDashboard,
callback?: Callback<T>,
): Promise<void | T> {
const config: RequestConfig = {
url: '/rest/api/2/dashboard',
method: 'POST',
params: {
extendAdminPermissions: parameters?.extendAdminPermissions,
extendAdminPermissions: parameters.extendAdminPermissions,
},
data: {
description: parameters?.description,
editPermissions: parameters?.editPermissions,
name: parameters?.name,
sharePermissions: parameters?.sharePermissions,
description: parameters.description,
editPermissions: parameters.editPermissions,
name: parameters.name,
sharePermissions: parameters.sharePermissions,
},
};

return this.client.sendRequest(config, callback);
}

/**
* Bulk edit dashboards. Maximum number of dashboards to be edited at the same time is 100.
*
Expand All @@ -89,7 +92,7 @@ export class Dashboards {
* The dashboards to be updated must be owned by the user, or the user must be an administrator.
*/
async bulkEditDashboards<T = Models.BulkEditShareableEntity>(
parameters: Parameters.BulkEditDashboards | undefined,
parameters: Parameters.BulkEditDashboards,
callback: Callback<T>,
): Promise<void>;
/**
Expand All @@ -100,27 +103,28 @@ export class Dashboards {
* The dashboards to be updated must be owned by the user, or the user must be an administrator.
*/
async bulkEditDashboards<T = Models.BulkEditShareableEntity>(
parameters?: Parameters.BulkEditDashboards,
parameters: Parameters.BulkEditDashboards,
callback?: never,
): Promise<T>;
async bulkEditDashboards<T = Models.BulkEditShareableEntity>(
parameters?: Parameters.BulkEditDashboards,
parameters: Parameters.BulkEditDashboards,
callback?: Callback<T>,
): Promise<void | T> {
const config: RequestConfig = {
url: '/rest/api/2/dashboard/bulk/edit',
method: 'PUT',
data: {
action: parameters?.action,
changeOwnerDetails: parameters?.changeOwnerDetails,
entityIds: parameters?.entityIds,
extendAdminPermissions: parameters?.extendAdminPermissions,
permissionDetails: parameters?.permissionDetails,
action: parameters.action,
changeOwnerDetails: parameters.changeOwnerDetails,
entityIds: parameters.entityIds,
extendAdminPermissions: parameters.extendAdminPermissions,
permissionDetails: parameters.permissionDetails,
},
};

return this.client.sendRequest(config, callback);
}

/**
* Gets a list of all available gadgets that can be added to all dashboards.
*
Expand All @@ -145,6 +149,7 @@ export class Dashboards {

return this.client.sendRequest(config, callback);
}

/**
* Returns a [paginated](https://developer.atlassian.com/cloud/jira/platform/rest/v2/intro/#pagination) list of
* dashboards. This operation is similar to [Get dashboards](#api-rest-api-2-dashboard-get) except that the results
Expand Down Expand Up @@ -210,6 +215,7 @@ export class Dashboards {

return this.client.sendRequest(config, callback);
}

/**
* Returns a list of dashboard gadgets on a dashboard.
*
Expand All @@ -225,7 +231,7 @@ export class Dashboards {
* **[Permissions](https://developer.atlassian.com/cloud/jira/platform/rest/v2/intro/#permissions) required:** None.
*/
async getAllGadgets<T = Models.DashboardGadgetResponse>(
parameters: Parameters.GetAllGadgets,
parameters: Parameters.GetAllGadgets | string,
callback: Callback<T>,
): Promise<void>;
/**
Expand All @@ -243,25 +249,28 @@ export class Dashboards {
* **[Permissions](https://developer.atlassian.com/cloud/jira/platform/rest/v2/intro/#permissions) required:** None.
*/
async getAllGadgets<T = Models.DashboardGadgetResponse>(
parameters: Parameters.GetAllGadgets,
parameters: Parameters.GetAllGadgets | string,
callback?: never,
): Promise<T>;
async getAllGadgets<T = Models.DashboardGadgetResponse>(
parameters: Parameters.GetAllGadgets,
parameters: Parameters.GetAllGadgets | string,
callback?: Callback<T>,
): Promise<void | T> {
const dashboardId = typeof parameters === 'string' ? parameters : parameters.dashboardId;

const config: RequestConfig = {
url: `/rest/api/2/dashboard/${parameters.dashboardId}/gadget`,
url: `/rest/api/2/dashboard/${dashboardId}/gadget`,
method: 'GET',
params: {
moduleKey: parameters.moduleKey,
uri: parameters.uri,
gadgetId: parameters.gadgetId,
moduleKey: typeof parameters !== 'string' && parameters.moduleKey,
uri: typeof parameters !== 'string' && parameters.uri,
gadgetId: typeof parameters !== 'string' && parameters.gadgetId,
},
};

return this.client.sendRequest(config, callback);
}

/**
* Adds a gadget to a dashboard.
*
Expand Down Expand Up @@ -293,6 +302,7 @@ export class Dashboards {

return this.client.sendRequest(config, callback);
}

/**
* Changes the title, position, and color of the gadget on a dashboard.
*
Expand All @@ -318,6 +328,7 @@ export class Dashboards {

return this.client.sendRequest(config, callback);
}

/**
* Removes a dashboard gadget from a dashboard.
*
Expand All @@ -344,6 +355,7 @@ export class Dashboards {

return this.client.sendRequest(config, callback);
}

/**
* Returns the keys of all properties for a dashboard item.
*
Expand All @@ -353,7 +365,7 @@ export class Dashboards {
* user must be the owner of the dashboard or have the dashboard shared with them. Note, users with the _Administer
* Jira_ [global permission](https://confluence.atlassian.com/x/x4dKLg) are considered owners of the System dashboard.
* The System dashboard is considered to be shared with all other users, and is accessible to anonymous users when
* Jira\u2019s anonymous access is permitted.
* Jira’s anonymous access is permitted.
*/
async getDashboardItemPropertyKeys<T = Models.PropertyKeys>(
parameters: Parameters.GetDashboardItemPropertyKeys,
Expand All @@ -368,7 +380,7 @@ export class Dashboards {
* user must be the owner of the dashboard or have the dashboard shared with them. Note, users with the _Administer
* Jira_ [global permission](https://confluence.atlassian.com/x/x4dKLg) are considered owners of the System dashboard.
* The System dashboard is considered to be shared with all other users, and is accessible to anonymous users when
* Jira\u2019s anonymous access is permitted.
* Jira’s anonymous access is permitted.
*/
async getDashboardItemPropertyKeys<T = Models.PropertyKeys>(
parameters: Parameters.GetDashboardItemPropertyKeys,
Expand All @@ -385,6 +397,7 @@ export class Dashboards {

return this.client.sendRequest(config, callback);
}

/**
* Returns the key and value of a dashboard item property.
*
Expand All @@ -408,7 +421,7 @@ export class Dashboards {
* user must be the owner of the dashboard or have the dashboard shared with them. Note, users with the _Administer
* Jira_ [global permission](https://confluence.atlassian.com/x/x4dKLg) are considered owners of the System dashboard.
* The System dashboard is considered to be shared with all other users, and is accessible to anonymous users when
* Jira\u2019s anonymous access is permitted.
* Jira’s anonymous access is permitted.
*/
async getDashboardItemProperty<T = Models.EntityProperty>(
parameters: Parameters.GetDashboardItemProperty,
Expand Down Expand Up @@ -437,7 +450,7 @@ export class Dashboards {
* user must be the owner of the dashboard or have the dashboard shared with them. Note, users with the _Administer
* Jira_ [global permission](https://confluence.atlassian.com/x/x4dKLg) are considered owners of the System dashboard.
* The System dashboard is considered to be shared with all other users, and is accessible to anonymous users when
* Jira\u2019s anonymous access is permitted.
* Jira’s anonymous access is permitted.
*/
async getDashboardItemProperty<T = Models.EntityProperty>(
parameters: Parameters.GetDashboardItemProperty,
Expand All @@ -454,6 +467,7 @@ export class Dashboards {

return this.client.sendRequest(config, callback);
}

/**
* Sets the value of a dashboard item property. Use this resource in apps to store custom data against a dashboard
* item.
Expand Down Expand Up @@ -523,10 +537,15 @@ export class Dashboards {
const config: RequestConfig = {
url: `/rest/api/2/dashboard/${parameters.dashboardId}/items/${parameters.itemId}/properties/${parameters.propertyKey}`,
method: 'PUT',
headers: {
'Content-Type': 'application/json',
},
data: parameters.propertyValue,
};

return this.client.sendRequest(config, callback);
}

/**
* Deletes a dashboard item property.
*
Expand Down Expand Up @@ -564,6 +583,7 @@ export class Dashboards {

return this.client.sendRequest(config, callback);
}

/**
* Returns a dashboard.
*
Expand All @@ -575,7 +595,10 @@ export class Dashboards {
* the _Administer Jira_ [global permission](https://confluence.atlassian.com/x/x4dKLg) are considered owners of the
* System dashboard. The System dashboard is considered to be shared with all other users.
*/
async getDashboard<T = Models.Dashboard>(parameters: Parameters.GetDashboard, callback: Callback<T>): Promise<void>;
async getDashboard<T = Models.Dashboard>(
parameters: Parameters.GetDashboard | string,
callback: Callback<T>,
): Promise<void>;
/**
* Returns a dashboard.
*
Expand All @@ -587,18 +610,21 @@ export class Dashboards {
* the _Administer Jira_ [global permission](https://confluence.atlassian.com/x/x4dKLg) are considered owners of the
* System dashboard. The System dashboard is considered to be shared with all other users.
*/
async getDashboard<T = Models.Dashboard>(parameters: Parameters.GetDashboard, callback?: never): Promise<T>;
async getDashboard<T = Models.Dashboard>(parameters: Parameters.GetDashboard | string, callback?: never): Promise<T>;
async getDashboard<T = Models.Dashboard>(
parameters: Parameters.GetDashboard,
parameters: Parameters.GetDashboard | string,
callback?: Callback<T>,
): Promise<void | T> {
const id = typeof parameters === 'string' ? parameters : parameters.id;

const config: RequestConfig = {
url: `/rest/api/2/dashboard/${parameters.id}`,
url: `/rest/api/2/dashboard/${id}`,
method: 'GET',
};

return this.client.sendRequest(config, callback);
}

/**
* Updates a dashboard, replacing all the dashboard details with those provided.
*
Expand Down Expand Up @@ -638,30 +664,40 @@ export class Dashboards {

return this.client.sendRequest(config, callback);
}

/**
* Deletes a dashboard.
*
* **[Permissions](https://developer.atlassian.com/cloud/jira/platform/rest/v2/intro/#permissions) required:** None
*
* The dashboard to be deleted must be owned by the user.
*/
async deleteDashboard<T = void>(parameters: Parameters.DeleteDashboard, callback: Callback<T>): Promise<void>;
async deleteDashboard<T = void>(
parameters: Parameters.DeleteDashboard | string,
callback: Callback<T>,
): Promise<void>;
/**
* Deletes a dashboard.
*
* **[Permissions](https://developer.atlassian.com/cloud/jira/platform/rest/v2/intro/#permissions) required:** None
*
* The dashboard to be deleted must be owned by the user.
*/
async deleteDashboard<T = void>(parameters: Parameters.DeleteDashboard, callback?: never): Promise<T>;
async deleteDashboard<T = void>(parameters: Parameters.DeleteDashboard, callback?: Callback<T>): Promise<void | T> {
async deleteDashboard<T = void>(parameters: Parameters.DeleteDashboard | string, callback?: never): Promise<T>;
async deleteDashboard<T = void>(
parameters: Parameters.DeleteDashboard | string,
callback?: Callback<T>,
): Promise<void | T> {
const id = typeof parameters === 'string' ? parameters : parameters.id;

const config: RequestConfig = {
url: `/rest/api/2/dashboard/${parameters.id}`,
url: `/rest/api/2/dashboard/${id}`,
method: 'DELETE',
};

return this.client.sendRequest(config, callback);
}

/**
* Copies a dashboard. Any values provided in the `dashboard` parameter replace those in the copied dashboard.
*
Expand Down
Loading
Loading