mirror of
https://github.com/encounter/tp.git
synced 2026-03-30 11:40:53 -07:00
c8bb857b13
* checkpoint * finish adding assignee support * test * use test command * use test command * skip build check * add state to common options, move version check * cleanup ok-check * undo dylink change
31 lines
762 B
Python
31 lines
762 B
Python
from .graphql import GraphQLClient
|
|
from logger import LOG
|
|
|
|
import sys
|
|
|
|
class User:
|
|
def __init__(self, id = None, name = None):
|
|
self.id = id
|
|
self.name = name
|
|
|
|
def get_id(self):
|
|
LOG.debug(f'Fetch ID for user {self.name}')
|
|
|
|
query = '''
|
|
query ($name: String!) {
|
|
user(login: $name) {
|
|
id
|
|
}
|
|
}
|
|
'''
|
|
variables = {
|
|
"name": self.name,
|
|
}
|
|
|
|
data = GraphQLClient.get_instance().make_request(query, variables)
|
|
if data:
|
|
self.id = data['data']['user']['id']
|
|
LOG.info(f"Found user {self.name} with ID {self.id}!")
|
|
else:
|
|
LOG.error(f'Failed to find user {self.name}!')
|
|
sys.exit(1) |