mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
✨ Add update/delete to Team, Release and Project in SentryIo node (#1605)
* Add update/delete to Team, Release and Project in SentryIo node * Add create/delete:Project in SentryIo node * Minor fix * Fix descriptions & display names * Fix casing in descriptions * Add getTeams load function & Update operations fields * Change 'Additional Field' to 'Update Fields' for Team,Release,Project & Organization operations
This commit is contained in:
@@ -279,6 +279,28 @@ export class SentryIo implements INodeType {
|
||||
return 0;
|
||||
});
|
||||
|
||||
return returnData;
|
||||
},
|
||||
// Get an organization teams
|
||||
async getTeams(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||
const returnData: INodePropertyOptions[] = [];
|
||||
|
||||
const organizationSlug = this.getNodeParameter('organizationSlug') as string;
|
||||
const teams = await sentryApiRequestAllItems.call(this, 'GET', `/api/0/organizations/${organizationSlug}/teams/`, {});
|
||||
|
||||
for (const team of teams) {
|
||||
returnData.push({
|
||||
name: team.slug,
|
||||
value: team.slug,
|
||||
});
|
||||
}
|
||||
|
||||
returnData.sort((a, b) => {
|
||||
if (a.name < b.name) { return -1; }
|
||||
if (a.name > b.name) { return 1; }
|
||||
return 0;
|
||||
});
|
||||
|
||||
return returnData;
|
||||
},
|
||||
},
|
||||
@@ -452,8 +474,36 @@ export class SentryIo implements INodeType {
|
||||
|
||||
responseData = await sentryIoApiRequest.call(this, 'POST', endpoint, qs);
|
||||
}
|
||||
if (operation === 'update') {
|
||||
const name = this.getNodeParameter('name', i) as string;
|
||||
const organizationSlug = this.getNodeParameter('organization_slug', i) as string;
|
||||
const updateFields = this.getNodeParameter('updateFields', i) as IDataObject;
|
||||
const endpoint = `/api/0/organizations/${organizationSlug}/`;
|
||||
|
||||
const body = {name};
|
||||
|
||||
if (updateFields.slug) {
|
||||
Object.assign(body, updateFields.slug as string);
|
||||
}
|
||||
|
||||
responseData = await sentryIoApiRequest.call(this, 'PUT', endpoint, body, qs);
|
||||
}
|
||||
}
|
||||
if (resource === 'project') {
|
||||
if (operation === 'create') {
|
||||
const organizationSlug = this.getNodeParameter('organizationSlug', i) as string;
|
||||
const teamSlug = this.getNodeParameter('teamSlug', i) as string;
|
||||
const name = this.getNodeParameter('name', i) as string;
|
||||
|
||||
const endpoint = `/api/0/teams/${organizationSlug}/${teamSlug}/projects/`;
|
||||
|
||||
const body = {
|
||||
name,
|
||||
...this.getNodeParameter('additionalFields', i) as IDataObject,
|
||||
};
|
||||
|
||||
responseData = await sentryIoApiRequest.call(this, 'POST', endpoint, body, qs);
|
||||
}
|
||||
if (operation === 'get') {
|
||||
const organizationSlug = this.getNodeParameter('organizationSlug', i) as string;
|
||||
const projectSlug = this.getNodeParameter('projectSlug', i) as string;
|
||||
@@ -477,6 +527,22 @@ export class SentryIo implements INodeType {
|
||||
responseData = responseData.splice(0, limit);
|
||||
}
|
||||
}
|
||||
if (operation === 'update') {
|
||||
const organizationSlug = this.getNodeParameter('organizationSlug', i) as string;
|
||||
const projectSlug = this.getNodeParameter('projectSlug', i) as string;
|
||||
const endpoint = `/api/0/projects/${organizationSlug}/${projectSlug}/`;
|
||||
const body = this.getNodeParameter('updateFields', i) as IDataObject;
|
||||
|
||||
responseData = await sentryIoApiRequest.call(this, 'PUT', endpoint, body, qs);
|
||||
}
|
||||
if (operation === 'delete') {
|
||||
const organizationSlug = this.getNodeParameter('organizationSlug', i) as string;
|
||||
const projectSlug = this.getNodeParameter('projectSlug', i) as string;
|
||||
const endpoint = `/api/0/projects/${organizationSlug}/${projectSlug}/`;
|
||||
|
||||
responseData = await sentryIoApiRequest.call(this, 'DELETE', endpoint, qs);
|
||||
responseData = { success: true };
|
||||
}
|
||||
}
|
||||
if (resource === 'release') {
|
||||
if (operation === 'get') {
|
||||
@@ -508,7 +574,13 @@ export class SentryIo implements INodeType {
|
||||
responseData = responseData.splice(0, limit);
|
||||
}
|
||||
}
|
||||
|
||||
if (operation === 'delete') {
|
||||
const organizationSlug = this.getNodeParameter('organizationSlug', i) as string;
|
||||
const version = this.getNodeParameter('version', i) as string;
|
||||
const endpoint = `/api/0/organizations/${organizationSlug}/releases/${version}/`;
|
||||
responseData = await sentryIoApiRequest.call(this, 'DELETE', endpoint, qs);
|
||||
responseData = { success: true };
|
||||
}
|
||||
if (operation === 'create') {
|
||||
const organizationSlug = this.getNodeParameter('organizationSlug', i) as string;
|
||||
const endpoint = `/api/0/organizations/${organizationSlug}/releases/`;
|
||||
@@ -571,6 +643,60 @@ export class SentryIo implements INodeType {
|
||||
|
||||
responseData = await sentryIoApiRequest.call(this, 'POST', endpoint, qs);
|
||||
}
|
||||
if (operation === 'update') {
|
||||
const organizationSlug = this.getNodeParameter('organizationSlug', i) as string;
|
||||
const version = this.getNodeParameter('version', i) as string;
|
||||
const endpoint = `/api/0/organizations/${organizationSlug}/releases/${version}/`;
|
||||
|
||||
const updateFields = this.getNodeParameter('updateFields', i) as IDataObject;
|
||||
|
||||
const body = {...updateFields};
|
||||
|
||||
if (updateFields.commits) {
|
||||
const commits: ICommit[] = [];
|
||||
//@ts-ignore
|
||||
// tslint:disable-next-line: no-any
|
||||
updateFields.commits.commitProperties.map((commit: any) => {
|
||||
const commitObject: ICommit = { id: commit.id };
|
||||
|
||||
if (commit.repository) {
|
||||
commitObject.repository = commit.repository;
|
||||
}
|
||||
if (commit.message) {
|
||||
commitObject.message = commit.message;
|
||||
}
|
||||
if (commit.patchSet && Array.isArray(commit.patchSet)) {
|
||||
commit.patchSet.patchSetProperties.map((patchSet: IPatchSet) => {
|
||||
commitObject.patch_set?.push(patchSet);
|
||||
});
|
||||
}
|
||||
if (commit.authorName) {
|
||||
commitObject.author_name = commit.authorName;
|
||||
}
|
||||
if (commit.authorEmail) {
|
||||
commitObject.author_email = commit.authorEmail;
|
||||
}
|
||||
if (commit.timestamp) {
|
||||
commitObject.timestamp = commit.timestamp;
|
||||
}
|
||||
|
||||
commits.push(commitObject);
|
||||
});
|
||||
|
||||
body.commits = commits;
|
||||
}
|
||||
if (updateFields.refs) {
|
||||
const refs: IRef[] = [];
|
||||
//@ts-ignore
|
||||
updateFields.refs.refProperties.map((ref: IRef) => {
|
||||
refs.push(ref);
|
||||
});
|
||||
|
||||
body.refs = refs;
|
||||
}
|
||||
|
||||
responseData = await sentryIoApiRequest.call(this, 'PUT', endpoint, body, qs);
|
||||
}
|
||||
}
|
||||
if (resource === 'team') {
|
||||
if (operation === 'get') {
|
||||
@@ -613,6 +739,30 @@ export class SentryIo implements INodeType {
|
||||
|
||||
responseData = await sentryIoApiRequest.call(this, 'POST', endpoint, qs);
|
||||
}
|
||||
if (operation === 'update') {
|
||||
const organizationSlug = this.getNodeParameter('organizationSlug', i) as string;
|
||||
const teamSlug = this.getNodeParameter('teamSlug', i) as string;
|
||||
const name = this.getNodeParameter('name', i) as string;
|
||||
const endpoint = `/api/0/teams/${organizationSlug}/${teamSlug}/`;
|
||||
|
||||
const updateFields = this.getNodeParameter('updateFields', i) as IDataObject;
|
||||
|
||||
const body={name};
|
||||
|
||||
if (updateFields.slug) {
|
||||
Object.assign(body, updateFields);
|
||||
}
|
||||
|
||||
responseData = await sentryIoApiRequest.call(this, 'PUT', endpoint, body, qs);
|
||||
}
|
||||
if (operation === 'delete') {
|
||||
const organizationSlug = this.getNodeParameter('organizationSlug', i) as string;
|
||||
const teamSlug = this.getNodeParameter('teamSlug', i) as string;
|
||||
const endpoint = `/api/0/teams/${organizationSlug}/${teamSlug}/`;
|
||||
|
||||
responseData = await sentryIoApiRequest.call(this, 'DELETE', endpoint, qs);
|
||||
responseData = { success: true };
|
||||
}
|
||||
}
|
||||
|
||||
if (Array.isArray(responseData)) {
|
||||
|
||||
Reference in New Issue
Block a user