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:
MedAliMarz 2021-04-24 00:37:37 +02:00 committed by GitHub
parent 35e790b8dd
commit a3c5f41b0f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 821 additions and 94 deletions

View file

@ -5,7 +5,7 @@ import {
export class SentryIoServerApi implements ICredentialType {
name = 'sentryIoServerApi';
displayName = 'Sentry.io API';
displayName = 'Sentry.io Server API';
documentationUrl = 'sentryIo';
properties = [
{

View file

@ -54,7 +54,7 @@ export const eventFields = [
},
},
required: true,
description: 'The slug of the organization the events belong to',
description: 'The slug of the organization the events belong to.',
},
{
displayName: 'Project Slug',
@ -78,7 +78,7 @@ export const eventFields = [
},
},
required: true,
description: 'The slug of the project the events belong to',
description: 'The slug of the project the events belong to.',
},
{
displayName: 'Full',
@ -95,7 +95,7 @@ export const eventFields = [
],
},
},
description: 'If this is set to true, then the event payload will include the full event body, including the stack trace',
description: 'If this is set to true, then the event payload will include the full event body, including the stack trace.',
},
{
displayName: 'Return All',
@ -112,7 +112,7 @@ export const eventFields = [
},
},
default: false,
description: 'If all results should be returned or only up to a given limit',
description: 'If all results should be returned or only up to a given limit.',
},
{
displayName: 'Limit',
@ -136,7 +136,7 @@ export const eventFields = [
maxValue: 500,
},
default: 100,
description: 'How many results to return',
description: 'How many results to return.',
},
/* -------------------------------------------------------------------------- */
/* event:get */
@ -160,7 +160,7 @@ export const eventFields = [
},
},
required: true,
description: 'The slug of the organization the events belong to',
description: 'The slug of the organization the events belong to.',
},
{
displayName: 'Project Slug',
@ -181,7 +181,7 @@ export const eventFields = [
},
},
required: true,
description: 'The slug of the project the events belong to',
description: 'The slug of the project the events belong to.',
},
{
displayName: 'Event ID',
@ -199,6 +199,6 @@ export const eventFields = [
},
},
required: true,
description: 'The id of the event to retrieve (either the numeric primary-key or the hexadecimal id as reported by the raven client).',
description: 'The ID of the event to retrieve (either the numeric primary-key or the hexadecimal ID as reported by the raven client).',
},
] as INodeProperties[];

View file

@ -63,7 +63,7 @@ export const issueFields = [
},
},
required: true,
description: 'ID of issue to get',
description: 'ID of issue to get.',
},
/* -------------------------------------------------------------------------- */
/* issue:getAll */
@ -87,7 +87,7 @@ export const issueFields = [
},
},
required: true,
description: 'The slug of the organization the issues belong to',
description: 'The slug of the organization the issues belong to.',
},
{
displayName: 'Project Slug',
@ -111,7 +111,7 @@ export const issueFields = [
},
},
required: true,
description: 'The slug of the project the issues belong to',
description: 'The slug of the project the issues belong to.',
},
{
displayName: 'Return All',
@ -128,7 +128,7 @@ export const issueFields = [
},
},
default: false,
description: 'If all results should be returned or only up to a given limit',
description: 'If all results should be returned or only up to a given limit.',
},
{
displayName: 'Limit',
@ -152,7 +152,7 @@ export const issueFields = [
maxValue: 500,
},
default: 100,
description: 'How many results to return',
description: 'How many results to return.',
},
{
displayName: 'Additional Fields',
@ -183,7 +183,7 @@ export const issueFields = [
name: 'statsPeriod',
type: 'options',
default: '',
description: 'Time period of stats',
description: 'Time period of stats.',
options: [
{
name: '14 Days',
@ -200,7 +200,7 @@ export const issueFields = [
name: 'shortIdLookUp',
type: 'boolean',
default: true,
description: 'If this is set to true then short IDs are looked up by this function as well. This can cause the return value of the function to return an event issue of a different project which is why this is an opt-in',
description: 'If this is set to true then short IDs are looked up by this function as well. This can cause the return value of the function to return an event issue of a different project which is why this is an opt-in.',
},
],
},
@ -224,10 +224,10 @@ export const issueFields = [
},
},
required: true,
description: 'ID of issue to get',
description: 'ID of issue to get.',
},
{
displayName: 'Additional Fields',
displayName: 'Update Fields',
name: 'additionalFields',
type: 'collection',
placeholder: 'Add Field',
@ -248,28 +248,28 @@ export const issueFields = [
name: 'assignedTo',
type: 'string',
default: '',
description: 'The actor id (or username) of the user or team that should be assigned to this issue',
description: 'The actor ID (or username) of the user or team that should be assigned to this issue.',
},
{
displayName: 'Has Seen',
name: 'hasSeen',
type: 'boolean',
default: true,
description: 'In case this API call is invoked with a user context this allows changing of the flag that indicates if the user has seen the event',
description: 'In case this API call is invoked with a user context this allows changing of the flag that indicates if the user has seen the event.',
},
{
displayName: 'Is Bookmarked',
name: 'isBookmarked',
type: 'boolean',
default: true,
description: 'In case this API call is invoked with a user context this allows changing of the bookmark flag',
description: 'In case this API call is invoked with a user context this allows changing of the bookmark flag.',
},
{
displayName: 'Is Public',
name: 'isPublic',
type: 'boolean',
default: true,
description: 'Sets the issue to public or private',
description: 'Sets the issue to public or private.',
},
{
displayName: 'Is Subscribed',
@ -282,7 +282,7 @@ export const issueFields = [
name: 'status',
type: 'options',
default: '',
description: 'The new status for the issue',
description: 'The new status for the issue.',
options: [
{
name: 'Ignored',

View file

@ -30,6 +30,11 @@ export const organizationOperations = [
value: 'getAll',
description: 'Get all organizations',
},
{
name: 'Update',
value: 'update',
description: 'Update an organization',
},
],
default: 'get',
description: 'The operation to perform',
@ -55,7 +60,7 @@ export const organizationFields = [
},
},
default: false,
description: 'If all results should be returned or only up to a given limit',
description: 'If all results should be returned or only up to a given limit.',
},
{
displayName: 'Limit',
@ -79,7 +84,7 @@ export const organizationFields = [
maxValue: 500,
},
default: 100,
description: 'How many results to return',
description: 'How many results to return.',
},
{
displayName: 'Additional Fields',
@ -103,14 +108,14 @@ export const organizationFields = [
name: 'member',
type: 'boolean',
default: true,
description: 'Restrict results to organizations which you have membership',
description: 'Restrict results to organizations which you have membership.',
},
{
displayName: 'Owner',
name: 'owner',
type: 'boolean',
default: true,
description: 'Restrict results to organizations which you are the owner',
description: 'Restrict results to organizations which you are the owner.',
},
],
},
@ -136,7 +141,7 @@ export const organizationFields = [
},
},
required: true,
description: 'The slug of the organization the team should be created for',
description: 'The slug of the organization the team should be created for.',
},
/* -------------------------------------------------------------------------- */
/* organization:create */
@ -157,7 +162,7 @@ export const organizationFields = [
},
},
required: true,
description: 'The slug of the organization the team should be created for',
description: 'The slug of the organization the team should be created for.',
},
{
displayName: 'Agree to Terms',
@ -174,7 +179,7 @@ export const organizationFields = [
],
},
},
description: 'Signaling you agree to the applicable terms of service and privacy policy of Sentry.io',
description: 'Signaling you agree to the applicable terms of service and privacy policy of Sentry.io.',
},
{
displayName: 'Additional Fields',
@ -198,7 +203,74 @@ export const organizationFields = [
name: 'slug',
type: 'string',
default: '',
description: 'The unique URL slug for this organization. If this is not provided a slug is automatically generated based on the name',
description: 'The unique URL slug for this organization. If this is not provided a slug is automatically generated based on the name.',
},
],
},
/* -------------------------------------------------------------------------- */
/* organization:update */
/* -------------------------------------------------------------------------- */
{
displayName: 'Slug',
name: 'organization_slug',
type: 'options',
typeOptions: {
loadOptionsMethod: 'getOrganizations',
},
displayOptions: {
show: {
resource: [
'organization',
],
operation: [
'update',
],
},
},
required: true,
description: 'The slug of the organization to update.',
},
{
displayName: 'Name',
name: 'name',
type: 'string',
default: '',
displayOptions: {
show: {
resource: [
'organization',
],
operation: [
'update',
],
},
},
required: true,
description: 'The name of the organization.',
},
{
displayName: 'Update Fields',
name: 'updateFields',
type: 'collection',
placeholder: 'Add Field',
default: {},
displayOptions: {
show: {
resource: [
'organization',
],
operation: [
'update',
],
},
},
options: [
{
displayName: 'Slug',
name: 'slug',
type: 'string',
default: '',
description: 'The updated URL slug for this organization.',
},
],
},

View file

@ -15,6 +15,11 @@ export const projectOperations = [
},
},
options: [
{
name: 'Create',
value: 'create',
description: 'Create a new project',
},
{
name: 'Get',
value: 'get',
@ -25,6 +30,16 @@ export const projectOperations = [
value: 'getAll',
description: 'Get all projects',
},
{
name: 'Update',
value: 'update',
description: 'Update a project',
},
{
name: 'Delete',
value: 'delete',
description: 'Delete a project',
},
],
default: 'get',
description: 'The operation to perform',
@ -51,13 +66,11 @@ export const projectFields = [
operation: [
'create',
'get',
'update',
'delete',
],
},
},
required: true,
description: 'The slug of the organization the events belong to',
description: 'The slug of the organization the events belong to.',
},
{
displayName: 'Project Slug',
@ -81,12 +94,18 @@ export const projectFields = [
},
},
required: true,
description: 'The slug of the project to retrieve',
description: 'The slug of the project to retrieve.',
},
{
displayName: 'Team Slug',
name: 'teamSlug',
type: 'string',
type: 'options',
typeOptions: {
loadOptionsMethod: 'getTeams',
loadOptionsDependsOn: [
'organizationSlug',
],
},
default: '',
displayOptions: {
show: {
@ -95,13 +114,11 @@ export const projectFields = [
],
operation: [
'create',
'update',
'delete',
],
},
},
required: true,
description: 'The slug of the team to create a new project for',
description: 'The slug of the team to create a new project for.',
},
{
displayName: 'Name',
@ -119,7 +136,7 @@ export const projectFields = [
},
},
required: true,
description: 'The name for the new project',
description: 'The name for the new project.',
},
{
displayName: 'Additional Fields',
@ -143,7 +160,7 @@ export const projectFields = [
name: 'slug',
type: 'string',
default: '',
description: 'Optionally a slug for the new project. If its not provided a slug is generated from the name',
description: 'Optionally a slug for the new project. If its not provided a slug is generated from the name.',
},
],
},
@ -165,7 +182,7 @@ export const projectFields = [
},
},
default: false,
description: 'If all results should be returned or only up to a given limit',
description: 'If all results should be returned or only up to a given limit.',
},
{
displayName: 'Limit',
@ -189,6 +206,170 @@ export const projectFields = [
maxValue: 500,
},
default: 100,
description: 'How many results to return',
description: 'How many results to return.',
},
/* -------------------------------------------------------------------------- */
/* project:update */
/* -------------------------------------------------------------------------- */
{
displayName: 'Organization Slug',
name: 'organizationSlug',
type: 'options',
typeOptions: {
loadOptionsMethod: 'getOrganizations',
},
default: '',
displayOptions: {
show: {
resource: [
'project',
],
operation: [
'update',
],
},
},
required: true,
description: 'The slug of the organization the project belong to.',
},
{
displayName: 'Project Slug',
name: 'projectSlug',
type: 'options',
typeOptions: {
loadOptionsMethod: 'getProjects',
loadOptionsDependsOn: [
'organizationSlug',
],
},
default: '',
displayOptions: {
show: {
resource: [
'project',
],
operation: [
'update',
],
},
},
required: true,
description: 'The slug of the project to update.',
},
{
displayName: 'Update Fields',
name: 'updateFields',
type: 'collection',
placeholder: 'Add Field',
default: {},
displayOptions: {
show: {
resource: [
'project',
],
operation: [
'update',
],
},
},
options: [
{
displayName: 'Team',
name: 'team',
type: 'string',
default: '',
description: 'The new team name.',
},
{
displayName: 'Name',
name: 'name',
type: 'string',
default: '',
description: 'The new name for the updated project.',
},
{
displayName: 'Slug',
name: 'slug',
type: 'string',
default: '',
description: 'The new slug for the updated project.',
},
{
displayName: 'Platform',
name: 'platform',
type: 'string',
default: '',
description: 'The new platform for the updated project.',
},
{
displayName: 'Bookmarked',
name: 'isBookmarked',
type: 'boolean',
default: false,
description: 'The new platform for the updated project.',
},
{
displayName: 'Digests Minimun Delay',
name: 'digestsMinDelay',
type: 'number',
default: 60,
description: 'Minium interval to digest alerts.',
},
{
displayName: 'Digests Maximum Delay',
name: 'digestsMaxDelay',
type: 'number',
default: 1800,
description: 'Maximum interval to digest alerts.',
},
],
},
/* -------------------------------------------------------------------------- */
/* project:delete */
/* -------------------------------------------------------------------------- */
{
displayName: 'Organization Slug',
name: 'organizationSlug',
type: 'options',
typeOptions: {
loadOptionsMethod: 'getOrganizations',
},
default: '',
displayOptions: {
show: {
resource: [
'project',
],
operation: [
'delete',
],
},
},
required: true,
description: 'The slug of the organization the project belong to.',
},
{
displayName: 'Project Slug',
name: 'projectSlug',
type: 'options',
typeOptions: {
loadOptionsMethod: 'getProjects',
loadOptionsDependsOn: [
'organizationSlug',
],
},
default: '',
displayOptions: {
show: {
resource: [
'project',
],
operation: [
'delete',
],
},
},
required: true,
description: 'The slug of the project to delete.',
},
] as INodeProperties[];

View file

@ -30,6 +30,16 @@ export const releaseOperations = [
value: 'getAll',
description: 'Get all releases',
},
{
name: 'Update',
value: 'update',
description: 'Update a release',
},
{
name: 'Delete',
value: 'delete',
description: 'Delete a release',
},
],
default: 'get',
description: 'The operation to perform',
@ -59,7 +69,7 @@ export const releaseFields = [
},
},
required: true,
description: 'The slug of the organization the releases belong to',
description: 'The slug of the organization the releases belong to.',
},
{
displayName: 'Return All',
@ -76,7 +86,7 @@ export const releaseFields = [
},
},
default: false,
description: 'If all results should be returned or only up to a given limit',
description: 'If all results should be returned or only up to a given limit.',
},
{
displayName: 'Limit',
@ -100,7 +110,7 @@ export const releaseFields = [
maxValue: 500,
},
default: 100,
description: 'How many results to return',
description: 'How many results to return.',
},
{
displayName: 'Additional Fields',
@ -124,12 +134,12 @@ export const releaseFields = [
name: 'query',
type: 'string',
default: '',
description: 'This parameter can be used to create a “starts with” filter for the version',
description: 'This parameter can be used to create a “starts with” filter for the version.',
},
],
},
/* -------------------------------------------------------------------------- */
/* release:get */
/* release:get/delete */
/* -------------------------------------------------------------------------- */
{
displayName: 'Organization Slug',
@ -146,11 +156,12 @@ export const releaseFields = [
],
operation: [
'get',
'delete',
],
},
},
required: true,
description: 'The slug of the organization the release belongs to',
description: 'The slug of the organization the release belongs to.',
},
{
displayName: 'Version',
@ -164,11 +175,12 @@ export const releaseFields = [
],
operation: [
'get',
'delete',
],
},
},
required: true,
description: 'The version identifier of the release',
description: 'The version identifier of the release.',
},
/* -------------------------------------------------------------------------- */
/* release:create */
@ -192,7 +204,7 @@ export const releaseFields = [
},
},
required: true,
description: 'The slug of the organization the release belongs to',
description: 'The slug of the organization the release belongs to.',
},
{
displayName: 'Version',
@ -210,7 +222,7 @@ export const releaseFields = [
},
},
required: true,
description: ' a version identifier for this release. Can be a version number, a commit hash etc',
description: 'A version identifier for this release. Can be a version number, a commit hash etc.',
},
{
displayName: 'URL',
@ -228,7 +240,7 @@ export const releaseFields = [
},
},
required: true,
description: 'A URL that points to the release. This can be the path to an online interface to the sourcecode for instance',
description: 'A URL that points to the release. This can be the path to an online interface to the sourcecode for instance.',
},
{
displayName: 'Projects',
@ -249,7 +261,7 @@ export const releaseFields = [
},
},
required: true,
description: 'A list of project slugs that are involved in this release',
description: 'A list of project slugs that are involved in this release.',
},
{
displayName: 'Additional Fields',
@ -273,12 +285,12 @@ export const releaseFields = [
name: 'dateReleased',
type: 'dateTime',
default: '',
description: 'an optional date that indicates when the release went live. If not provided the current time is assumed',
description: 'An optional date that indicates when the release went live. If not provided the current time is assumed.',
},
{
displayName: 'Commits',
name: 'commits',
description: 'an optional list of commit data to be associated with the release',
description: 'An optional list of commit data to be associated with the release.',
type: 'fixedCollection',
typeOptions: {
multipleValues: true,
@ -290,11 +302,11 @@ export const releaseFields = [
displayName: 'Commit Properties',
values: [
{
displayName: 'Id',
displayName: 'ID',
name: 'id',
type: 'string',
default: '',
description: 'the sha of the commit',
description: 'The sha of the commit.',
required: true,
},
{
@ -302,26 +314,26 @@ export const releaseFields = [
name: 'authorEmail',
type: 'string',
default: '',
description: 'Authors email',
description: 'Authors email.',
},
{
displayName: 'Author Name',
name: 'authorName',
type: 'string',
default: '',
description: 'Name of author',
description: 'Name of author.',
},
{
displayName: 'Message',
name: 'message',
type: 'string',
default: '',
description: 'Message of commit',
description: 'Message of commit.',
},
{
displayName: 'Patch Set',
name: 'patchSet',
description: 'A list of the files that have been changed in the commit. Specifying the patch_set is necessary to power suspect commits and suggested assignees',
description: 'A list of the files that have been changed in the commit. Specifying the patch_set is necessary to power suspect commits and suggested assignees.',
type: 'fixedCollection',
typeOptions: {
multipleValues: true,
@ -337,7 +349,7 @@ export const releaseFields = [
name: 'path',
type: 'string',
default: '',
description: 'he path to the file. Both forward and backward slashes are supported',
description: 'The path to the file. Both forward and backward slashes are supported.',
required: true,
},
{
@ -345,7 +357,7 @@ export const releaseFields = [
name: 'type',
type: 'options',
default: '',
description: 'he types of changes that happend in that commit',
description: 'The types of changes that happend in that commit.',
options: [
{
name: 'Add',
@ -370,14 +382,14 @@ export const releaseFields = [
name: 'repository',
type: 'string',
default: '',
description: 'Repository name',
description: 'Repository name.',
},
{
displayName: 'Timestamp',
name: 'timestamp',
type: 'dateTime',
default: '',
description: 'Timestamp of commit',
description: 'Timestamp of commit.',
},
],
},
@ -386,7 +398,7 @@ export const releaseFields = [
{
displayName: 'Refs',
name: 'refs',
description: 'an optional way to indicate the start and end commits for each repository included in a release',
description: 'An optional way to indicate the start and end commits for each repository included in a release.',
type: 'fixedCollection',
typeOptions: {
multipleValues: true,
@ -402,7 +414,7 @@ export const releaseFields = [
name: 'commit',
type: 'string',
default: '',
description: 'the head sha of the commit',
description: 'The head sha of the commit.',
required: true,
},
{
@ -410,7 +422,7 @@ export const releaseFields = [
name: 'repository',
type: 'string',
default: '',
description: 'Repository name',
description: 'Repository name.',
required: true,
},
{
@ -418,7 +430,238 @@ export const releaseFields = [
name: 'previousCommit',
type: 'string',
default: '',
description: 'the sha of the HEAD of the previous release',
description: 'The sha of the HEAD of the previous release.',
},
],
},
],
},
],
},
/* -------------------------------------------------------------------------- */
/* release:update */
/* -------------------------------------------------------------------------- */
{
displayName: 'Organization Slug',
name: 'organizationSlug',
type: 'options',
typeOptions: {
loadOptionsMethod: 'getOrganizations',
},
default: '',
displayOptions: {
show: {
resource: [
'release',
],
operation: [
'update',
],
},
},
required: true,
description: 'The slug of the organization the release belongs to.',
},
{
displayName: 'Version',
name: 'version',
type: 'string',
default: '',
displayOptions: {
show: {
resource: [
'release',
],
operation: [
'update',
],
},
},
required: true,
description: 'A version identifier for this release. Can be a version number, a commit hash etc.',
},
{
displayName: 'Update Fields',
name: 'updateFields',
type: 'collection',
placeholder: 'Add Field',
default: {},
displayOptions: {
show: {
resource: [
'release',
],
operation: [
'update',
],
},
},
options: [
{
displayName: 'Ref',
name: 'ref',
type: 'string',
default: '',
description: 'A URL that points to the release. This can be the path to an online interface to the sourcecode for instance.',
},
{
displayName: 'URL',
name: 'url',
type: 'string',
default: '',
description: 'A URL that points to the release. This can be the path to an online interface to the sourcecode for instance.',
},
{
displayName: 'Date released',
name: 'dateReleased',
type: 'dateTime',
default: '',
description: 'an optional date that indicates when the release went live. If not provided the current time is assumed.',
},
{
displayName: 'Commits',
name: 'commits',
description: 'An optional list of commit data to be associated with the release.',
type: 'fixedCollection',
typeOptions: {
multipleValues: true,
},
default: {},
options: [
{
name: 'commitProperties',
displayName: 'Commit Properties',
values: [
{
displayName: 'ID',
name: 'id',
type: 'string',
default: '',
description: 'The sha of the commit.',
required: true,
},
{
displayName: 'Author Email',
name: 'authorEmail',
type: 'string',
default: '',
description: 'Authors email.',
},
{
displayName: 'Author Name',
name: 'authorName',
type: 'string',
default: '',
description: 'Name of author.',
},
{
displayName: 'Message',
name: 'message',
type: 'string',
default: '',
description: 'Message of commit.',
},
{
displayName: 'Patch Set',
name: 'patchSet',
description: 'A list of the files that have been changed in the commit. Specifying the patch_set is necessary to power suspect commits and suggested assignees.',
type: 'fixedCollection',
typeOptions: {
multipleValues: true,
},
default: {},
options: [
{
name: 'patchSetProperties',
displayName: 'Patch Set Properties',
values: [
{
displayName: 'Path',
name: 'path',
type: 'string',
default: '',
description: 'The path to the file. Both forward and backward slashes are supported.',
required: true,
},
{
displayName: 'Type',
name: 'type',
type: 'options',
default: '',
description: 'The types of changes that happend in that commit.',
options: [
{
name: 'Add',
value: 'add',
},
{
name: 'Modify',
value: 'modify',
},
{
name: 'Delete',
value: 'delete',
},
],
},
],
},
],
},
{
displayName: 'Repository',
name: 'repository',
type: 'string',
default: '',
description: 'Repository name.',
},
{
displayName: 'Timestamp',
name: 'timestamp',
type: 'dateTime',
default: '',
description: 'Timestamp of commit.',
},
],
},
],
},
{
displayName: 'Refs',
name: 'refs',
description: 'An optional way to indicate the start and end commits for each repository included in a release.',
type: 'fixedCollection',
typeOptions: {
multipleValues: true,
},
default: {},
options: [
{
name: 'refProperties',
displayName: 'Ref Properties',
values: [
{
displayName: 'Commit',
name: 'commit',
type: 'string',
default: '',
description: 'The head sha of the commit.',
required: true,
},
{
displayName: 'Repository',
name: 'repository',
type: 'string',
default: '',
description: 'Repository name.',
required: true,
},
{
displayName: 'Previous Commit',
name: 'previousCommit',
type: 'string',
default: '',
description: 'The sha of the HEAD of the previous release.',
},
],
},

View file

@ -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)) {

View file

@ -30,6 +30,16 @@ export const teamOperations = [
value: 'getAll',
description: 'Get all teams',
},
{
name: 'Update',
value: 'update',
description: 'Update a team',
},
{
name: 'Delete',
value: 'delete',
description: 'Delete a team',
},
],
default: 'get',
description: 'The operation to perform',
@ -59,7 +69,7 @@ export const teamFields = [
},
},
required: true,
description: 'The slug of the organization for which the teams should be listed',
description: 'The slug of the organization for which the teams should be listed.',
},
{
displayName: 'Return All',
@ -76,7 +86,7 @@ export const teamFields = [
},
},
default: false,
description: 'If all results should be returned or only up to a given limit',
description: 'If all results should be returned or only up to a given limit.',
},
{
displayName: 'Limit',
@ -100,7 +110,7 @@ export const teamFields = [
maxValue: 500,
},
default: 100,
description: 'How many results to return',
description: 'How many results to return.',
},
/* -------------------------------------------------------------------------- */
/* team:get */
@ -124,12 +134,18 @@ export const teamFields = [
},
},
required: true,
description: 'The slug of the organization the team belongs to',
description: 'The slug of the organization the team belongs to.',
},
{
displayName: 'Team Slug',
name: 'teamSlug',
type: 'string',
type: 'options',
typeOptions: {
loadOptionsMethod: 'getTeams',
loadOptionsDependsOn: [
'organizationSlug',
],
},
default: '',
displayOptions: {
show: {
@ -142,7 +158,7 @@ export const teamFields = [
},
},
required: true,
description: 'The slug of the team to get',
description: 'The slug of the team to get.',
},
/* -------------------------------------------------------------------------- */
/* team:create */
@ -166,7 +182,7 @@ export const teamFields = [
},
},
required: true,
description: 'The slug of the organization the team belongs to',
description: 'The slug of the organization the team belongs to.',
},
{
displayName: 'Name',
@ -184,7 +200,7 @@ export const teamFields = [
},
},
required: true,
description: 'The name of the team',
description: 'The name of the team.',
},
{
displayName: 'Additional Fields',
@ -208,7 +224,7 @@ export const teamFields = [
name: 'slug',
type: 'string',
default: '',
description: 'The optional slug for this team. If not provided it will be auto generated from the name',
description: 'The optional slug for this team. If not provided it will be auto generated from the name.',
},
],
},
@ -229,16 +245,40 @@ export const teamFields = [
'team',
],
operation: [
'update', 'delete',
'update',
],
},
},
required: true,
description: 'The slug of the organization the team belongs to',
description: 'The slug of the organization the team belongs to.',
},
{
displayName: 'Team Slug',
name: 'teamSlug',
type: 'options',
typeOptions: {
loadOptionsMethod: 'getTeams',
loadOptionsDependsOn: [
'organizationSlug',
],
},
default: '',
displayOptions: {
show: {
resource: [
'team',
],
operation: [
'update',
],
},
},
required: true,
description: 'The slug of the team to update.',
},
{
displayName: 'Name',
name: 'name',
type: 'string',
default: '',
displayOptions: {
@ -247,16 +287,16 @@ export const teamFields = [
'team',
],
operation: [
'update', 'delete',
'update',
],
},
},
required: true,
description: 'The slug of the team to get',
description: 'The new name of the team.',
},
{
displayName: 'Additional Fields',
name: 'additionalFields',
displayName: 'Update Fields',
name: 'updateFields',
type: 'collection',
placeholder: 'Add Field',
default: {},
@ -276,15 +316,56 @@ export const teamFields = [
name: 'slug',
type: 'string',
default: '',
description: 'The new slug of the team. Must be unique and available',
},
{
displayName: 'Name',
name: 'name',
type: 'string',
default: '',
description: 'The new name of the team',
description: 'The new slug of the team. Must be unique and available.',
},
],
},
/* -------------------------------------------------------------------------- */
/* team:delete */
/* -------------------------------------------------------------------------- */
{
displayName: 'Organization Slug',
name: 'organizationSlug',
type: 'options',
typeOptions: {
loadOptionsMethod: 'getOrganizations',
},
default: '',
displayOptions: {
show: {
resource: [
'team',
],
operation: [
'delete',
],
},
},
required: true,
description: 'The slug of the organization the team belongs to.',
},
{
displayName: 'Team Slug',
name: 'teamSlug',
type: 'options',
typeOptions: {
loadOptionsMethod: 'getTeams',
loadOptionsDependsOn: [
'organizationSlug',
],
},
default: '',
displayOptions: {
show: {
resource: [
'team',
],
operation: [
'delete',
],
},
},
required: true,
description: 'The slug of the team to delete.',
},
] as INodeProperties[];