# Working with Queues, Tasks, Resources, and Logs

> Starting from version 1.27, all platform components support accessing queues, tasks, resources, and logs not only by GUID but also by their names.

Below are examples of calls to resources, tasks, and logs of the Orchestrator. These requests can be executed from the Python robot code as needed.

```
import base64
import json
from requests.packages.urllib3.exceptions import InsecureRequestWarning
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
host = 'http://192.168.1.111:4500' #orchestrator host
robot_guid = 'da8bc2f0-8065-4385-b867-405e66b8e151' #robot GUID
headers = {
    'Authorization': 'Basic ' + base64.b64encode(robot_guid.encode('utf-8')).decode('utf-8')
}

#Adding a new task to the task queue '0cff3e77-78fc-405e-98c9-ef5076c0c883'
new_task = {
            'queue_guid': '0cff3e77-78fc-405e-98c9-ef5076c0c883',
            'name': 'New Task',
            'parameters': json.dumps({'query_id': '123', 'query_link': 'D:\CommonFolder\Packet123.zip', 'query_status': 'new', 'doc_type': 'PTS', 'doc_status': 'new'})
}
r = requests.post(host + '/api/task/create', data=new_task, headers=headers, verify=False)

#For control, we output the result of the request - GUID of the created task
added_task = json.loads(r.text)
print('GUID of added task: ', added_task ['guid'])

#Getting the last task in the queue (without filters)
r = requests.get(host + '/api/queue/lastTask/0cff3e77-78fc-405e-98c9-ef5076c0c883', headers=headers, verify=False)
print('api/queue/lastTask result', r)
print('    ', r.text)
new_task = json.loads(r.text)

#Task status reference
STATUS_NEW   = 0;    #New task
STATUS_IN_PROGRESS  = 1;   #Task in progress
STATUS_SUCCESS  = 2;    #Task successfully completed
STATUS_FAILED  = 3; #Task failed with Application Exception
STATUS_FAILED_BUSINESS  = 4; #Task failed with Business Exception
STATUS_POSTPONED   = 5;   #Task postponed until specified time
STATUS_ABANDONED   = 6;  #Task abandoned (not processed in time)

#Updating the status of the previously received task
task_update = {
    'guid': new_task['guid'],
    'status': 1
}
r = requests.put(host + '/api/task/update', data=task_update, headers=headers, verify=False)
print('/api/task/update result', r.text)

#Getting the resource (asset)
r = requests.get(host + '/api/asset/read/533daa45-8c3e-42ff-a5ae-b5023715d929', headers=headers, verify=False)
print('/api/asset/read/ result', r.text)
asset = json.loads(r.text)

#Updating the resource
asset_update = {
    'guid': asset['guid'],
    'name': 'new name',  #Resource name
    'text': 'new text',  #Text, login (for Credentials type) or serialized calendar
    'password': 'new password'  #New password
}
r = requests.put(host + '/api/asset/update', data=asset_update, headers=headers, verify=False)
print('/api/asset/update/ result', r.text)

#Adding a new entry to the log
new_log = {
    'robot_guid': '9be0687d-4e00-4742-a53f-c9b622d076db',
    'process_version_guid': '4443fc75-4b55-41a2-bb61-9132b6e55d6b',
    'job_guid': '55056968-cb1b-4919-ad7b-9370c6e81e55',
    'level': 'Info',   #Allowed values 'Info', 'Critical', 'Error', 'Warning', 'Debug'
    'message': 'New message'
}
r = requests.post(host + '/api/log/create', data=new_log, headers=headers, verify=False)
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.sherparpa.ru/en/sherpa-rpa/sherpa-orchestrator/python-sherpa-framework/rabota-s-ocheredyami-zadachami-resursami-i-logami.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
