Compare commits
No commits in common. "2edd6fd3dfc0931f24350c394ec5e95c9a1382c3" and "0b668f85c5ae564fab8f440e3d8c5a0de00c8bfa" have entirely different histories.
2edd6fd3df
...
0b668f85c5
@ -1,76 +0,0 @@
|
|||||||
import csv
|
|
||||||
import json
|
|
||||||
import os
|
|
||||||
import sys
|
|
||||||
import time
|
|
||||||
|
|
||||||
import requests
|
|
||||||
|
|
||||||
|
|
||||||
from logging_config import setup_logging
|
|
||||||
from urllib.parse import urlencode
|
|
||||||
|
|
||||||
logger = setup_logging(__name__)
|
|
||||||
|
|
||||||
base_dir = os.path.dirname(os.path.realpath(__file__))
|
|
||||||
asana_data_json = os.path.join(base_dir, './data/data_asana.json')
|
|
||||||
users_data = os.path.join(base_dir, './data/users.mapping.asana2ya.csv')
|
|
||||||
|
|
||||||
sys.stdin.reconfigure(encoding='utf-8')
|
|
||||||
sys.stdout.reconfigure(encoding='utf-8')
|
|
||||||
|
|
||||||
|
|
||||||
QUEUE_NAME = 'TESTIMPORT'
|
|
||||||
|
|
||||||
# headers = {
|
|
||||||
# 'Host': 'api.tracker.yandex.net',
|
|
||||||
# 'Authorization': 'OAuth y0_AgAEA7qkB3KjAArkXwAAAADzMlP9oR1lwMzBS2e94jHzdnII8Laxi7k',
|
|
||||||
# 'X-Org-ID': '7095769',
|
|
||||||
# 'Content-Type': 'appication/json',
|
|
||||||
# }
|
|
||||||
|
|
||||||
|
|
||||||
def close_tasks_in_queue(queue_name):
|
|
||||||
base_url = 'https://api.tracker.yandex.net/v2/issues/_search'
|
|
||||||
headers = {
|
|
||||||
'Host': 'api.tracker.yandex.net',
|
|
||||||
'Authorization': 'OAuth y0_AgAEA7qkB3KjAArkXwAAAADzMlP9oR1lwMzBS2e94jHzdnII8Laxi7k',
|
|
||||||
'X-Org-ID': '7095769',
|
|
||||||
'Content-Type': 'application/json',
|
|
||||||
}
|
|
||||||
|
|
||||||
payload = {
|
|
||||||
"filter": {
|
|
||||||
"queue": queue_name,
|
|
||||||
"status": "open" # Фильтр для открытых задач в указанной очереди
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
response = requests.post(
|
|
||||||
base_url,
|
|
||||||
headers=headers,
|
|
||||||
data=json.dumps(payload)
|
|
||||||
)
|
|
||||||
|
|
||||||
if response.status_code == 200:
|
|
||||||
tasks = response.json().get('issues', [])
|
|
||||||
for task in tasks:
|
|
||||||
task_id = task['id']
|
|
||||||
close_payload = {
|
|
||||||
'status': 'resolved' # Установка статуса "Закрыт"
|
|
||||||
}
|
|
||||||
close_url = f'https://api.tracker.yandex.net/v2/issues/{task_id}'
|
|
||||||
close_response = requests.patch(
|
|
||||||
close_url,
|
|
||||||
headers=headers,
|
|
||||||
data=json.dumps(close_payload)
|
|
||||||
)
|
|
||||||
if close_response.status_code == 200:
|
|
||||||
print(f'Задача {task_id} закрыта успешно')
|
|
||||||
else:
|
|
||||||
print(f'Ошибка при закрытии задачи {task_id}: {close_response.content}')
|
|
||||||
else:
|
|
||||||
print(f'Ошибка при получении задач для очереди {queue_name}: {response.content}')
|
|
||||||
|
|
||||||
# Вызов функции для закрытия задач в очереди 'TESTIMPORT'
|
|
||||||
close_tasks_in_queue('TESTIMPORT')
|
|
Loading…
Reference in New Issue
Block a user