How can I Delete externalEventSourceId for specific eventType using the RestAPI
or GraphQL using a curl command?
I ran into a limit and all my rest api scripts are failing now, as there is no way to delete this data
https://community.atlassian.com/t5/Compass-questions/ATTACHED-EVENT-SOURCE-LIMIT-REACHED/qaq-p/2942043
example script:
#!/usr/bin/env bashset -eCOMPASS_CLOUD_INSTANCE=acmeCOMPASS_REST_API_VERSION=v1## create api token for your user https://id.atlassian.com/manage-profile/security## @todo pull from ENV VariableCOMPASS_USER_EMAIL=me@email.comCOMPASS_USER_TOKEN=super.long.token.hereCLOUD_ID="3123123123-2222-47d0-8ad2-7sdfe5td"## https://hello.atlassian.net/gateway/api/graphqlCOMPASS_BASE_URL="https://$COMPASS_CLOUD_INSTANCE.atlassian.net/gateway/api/graphql"echo "COMPASS_BASE_URL: $COMPASS_BASE_URL"# The GraphQL query you want to executeQUERY="mutation DeleteEventSourceMutation { compass { deleteEventSource( input: { cloudId: \"$CLOUD_ID\", externalEventSourceId: \"text-of-external-event-source-id\", eventType: \"DEPLOYMENT\" } ) { success } }}"echo "QUERY: $QUERY"# Construct the GraphQL requestREQUEST_BODY=$(jq -n --arg query "$QUERY" '{query: $query}')echo "REQUEST_BODY: $REQUEST_BODY"## X-ExperimentalApi: DevOpsBeta## X-ExperimentalApi: compass-beta# COMPASS_GRAPHQL=$(curl -g \# --request POST \# --url $COMPASS_BASE_URL \# --user $COMPASS_USER_EMAIL:$COMPASS_USER_TOKEN \# --header 'Accept: application/json' \# --header 'Content-Type: application/json' \# --header 'X-ExperimentalApi: DevOpsBeta' \# --data "$REQUEST_BODY")COMPASS_GRAPHQL=$(curl -s -X POST \-H "Authorization: Bearer $COMPASS_USER_TOKEN" \-H "Content-Type: application/json" \-d "$REQUEST_BODY" \"$COMPASS_BASE_URL")echo "COMPASS_GRAPHQL: $COMPASS_GRAPHQL"
For manually-added event sources, you can delete them using the GraphQL API.
Example:
curl -X POST \ -u "yourUsernameEmail:your-long-api-key" \ -H "Content-Type: application/json" \ -H "X-ExperimentalApi: DevOpsBeta" \ -H "X-ExperimentalApi: compass-beta" \ -d '{ "query": "mutation DeleteEventSourceMutation { compass { deleteEventSource( input: { cloudId: \"your-cloud-id\", externalEventSourceId: \"test_id\", eventType: ALERT } ) { success errors { message extensions { statusCode errorType}} } } }" }' \https://your-site.atlassian.net/gateway/api/graphql
Note that `eventType` is an enum and not a string, so no need for quotes around that or otherwise it'd throw a validation error.
You need to be a Compass admin to have permission to do this as well.
(To test your queries, it can also be faster to use the GraphQL explorer, in your-site.atlassian.net/gateway/api/graphql )
OMG YES!, this is so much easier
your-site.atlassian.net/gateway/api/graphql
Follow up question:
since Bamboo does not have access to Bitbucket repo UUID, would using the first commit hash be acceptable and an externalEventSourceId?
git rev-list --parents HEAD | tail -1
@Phill Pafford that makes sense to me, since that's going to still be a unique UUID.
I'm glad this helped solve it!
It looks like you're new here. Sign in or register to get started.