diff --git a/tools/scripts/gql.py b/tools/scripts/gql.py deleted file mode 100644 index c1b26cf3027..00000000000 --- a/tools/scripts/gql.py +++ /dev/null @@ -1,180 +0,0 @@ -import os -from typing import Any - -import requests - -GRAPHQL_URL = "https://api.github.com/graphql" - -DEBUG = os.environ.get("DET_DEBUG") == "1" - - -class GraphQLQuery(str): - def __call__(self, **args: Any) -> Any: - if DEBUG: - print("================ GraphQL query") - print(self.strip()) - print(args) - r = requests.post( - GRAPHQL_URL, - headers={"Authorization": "bearer " + os.environ["GITHUB_TOKEN"]}, - json={"query": self, "variables": args}, - ) - r.raise_for_status() - j = r.json() - if DEBUG: - print(j) - try: - return j["data"] - except Exception: - print(j) - raise - - -get_repo_id = GraphQLQuery( - """ -query($owner: String!, $name: String!) { - repository(owner: $owner, name: $name) { - id - } -} -""" -) - -search_projects = GraphQLQuery( - """ -query($owner: String!, $q: String!) { - organization(login: $owner) { - projectsV2(query: $q, first: 100) { - nodes { - id - title - } - } - } -} -""" -) - -create_issue = GraphQLQuery( - """ -mutation($repo: ID!, $title: String!, $body: String!) { - createIssue(input: {repositoryId: $repo, title: $title, body: $body}) { - issue { - id - } - } -} -""" -) - -add_item_to_project = GraphQLQuery( - """ -mutation($project: ID!, $item: ID!) { - addProjectV2ItemById(input: {projectId: $project, contentId: $item}) { - item { - id - } - } -} -""" -) - -get_status_field_info = GraphQLQuery( - """ -query($project: ID!) { - node(id: $project) { - ... on ProjectV2 { - field(name: "Status") { - ... on ProjectV2SingleSelectField { - id - options { - id - name - } - } - } - } - } -} -""" -) - -set_project_item_status = GraphQLQuery( - """ -mutation($project: ID!, $item: ID!, $field: ID!, $value: String) { - updateProjectV2ItemFieldValue( - input: { - projectId: $project, itemId: $item, fieldId: $field, value: {singleSelectOptionId: $value} - } - ) { - projectV2Item { - id - } - } -} -""" -) - -get_pr_info = GraphQLQuery( - """ -query($id: ID!) { - node(id: $id) { - ... on PullRequest { - number - title - url - body - repository { - owner { - login - } - name - } - } - } -} -""" -) - - -get_pr_title = GraphQLQuery( - """ -query($id: ID!) { - node(id: $id) { - ... on PullRequest { - title - } - } -} -""" -) - -list_project_prs = GraphQLQuery( - """ -query($project: ID!, $after: String) { - node(id: $project) { - ... on ProjectV2 { - items(first: 100, after: $after) { - nodes { - id - fieldValueByName(name: "Status") { - ... on ProjectV2ItemFieldSingleSelectValue { - name - } - } - content { - ... on PullRequest { - id - } - } - } - pageInfo { - endCursor - hasNextPage - } - } - } - } -} -""" -)