nautobot / nautobot-app-version-control

Version Control App that uses and requires a Dolt Database
Other
30 stars 6 forks source link

A GET for pull requests does not contain the UUID for each pull request #136

Closed tim-fiola closed 2 years ago

tim-fiola commented 2 years ago

A REST call to get pull requests does not return the UUID in the info for each pull request.

image

A UUID for the PR is needed to programmatically modify pull request reviews, as shown here:

import requests
import json

url = "http://0.0.0.0:8080/api/plugins/dolt/pull_requests_reviews/"

state = 0  # 0 = comment, 1 = approved, 2 = blocked

# Problems to solve:
# - getting the pull request UUID

payload = json.dumps({
  "pull_request": "92eb3092-361d-4356-bf1c-934a336bcb62",  # <--- we need pull_request UUID to add a PR review/comment
  "reviewer": "71cbe632-c69a-40a5-9c0f-e75fba2bdf53",
  "state": 0,
  "summary": "this is from a python script again"
})
headers = {
  'Authorization': 'Token nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn',
  'Content-Type': 'application/json'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

If the UUID for each PR is not available when querying for PRs, users will be unable to programmatically query for a given pull request and modify specific pull request reviews because pull requests are referenced by UUID, as shown in the code above.

jathanism commented 2 years ago

In fact none of the objects are returning ID numbers so we'll just make sure we add them across the board. This is a pretty quick fix.