print(login_response.status_code)
    if login_response.json()["error"] and login_response.json(
    )["error_description"]:
        print(login_response.json()["error"])
        print(login_response.json()["error_description"])
    else:
        print(login_response.text)
    sys.exit()  # exit script if login not successful

# get list of rooms

parentID = 59

r = nodes.search_nodes('*',
                       parentID=parentID,
                       depthLevel=-1,
                       offset=0,
                       filter='type:eq:room')
try:
    room_response = my_dracoon.get(r)
except core.requests.exceptions.RequestException as e:
    raise SystemExit(e)

if room_response.status_code == 200:
    parent_list = room_response.json()["items"]
else:
    e = f'Error getting rooms - details: {room_response.text}'
    raise SystemExit(e)

# provide a list (or single id for parent)
if login_response.status_code == 200:
    print('Login successful: ' + str(login_response.status_code))
else:
    print(login_response.status_code)
    if login_response.json()["error"] and login_response.json(
    )["error_description"]:
        print(login_response.json()["error"])
        print(login_response.json()["error_description"])
    else:
        print(login_response.text)
    sys.exit()  # exit script if login not successful

# create request to get search for all files with expiration date greater than November 29th 2020
r = nodes.search_nodes('*',
                       parentID=0,
                       depthLevel=-1,
                       offset=0,
                       filter='type:eq:file|size:le:1')

# perform request with authenticated DRACOON instance
try:
    file_response = my_dracoon.get(r)
except core.requests.exceptions.RequestException as e:
    raise SystemExit(e)

file_list = []

# if call successful, check populate list
if file_response.status_code == 200:

    # add files to list
Exemplo n.º 3
0
if login_response.status_code == 200:
    print('Login successful: ' + str(login_response.status_code))
else:
    print(login_response.status_code)
    if login_response.json()["error"] and login_response.json(
    )["error_description"]:
        print(login_response.json()["error"])
        print(login_response.json()["error_description"])
    else:
        print(login_response.text)
    sys.exit()  # exit script if login not successful

# create request to get search for all files with expiration date greater than November 29th 2020
r = nodes.search_nodes('*',
                       parentID=0,
                       depthLevel=-1,
                       offset=0,
                       filter='type:eq:file|expireAt:ge:2020-11-29')

# perform request with authenticated DRACOON instance
try:
    file_response = my_dracoon.get(r)
except core.requests.exceptions.RequestException as e:
    raise SystemExit(e)

file_list = []

# if call successful, check populate list
if file_response.status_code == 200:

    # add files to list
Exemplo n.º 4
0
    },
    {
        "file": "_liesmich.txt",
        "date_modification": "2021-02-09T09:00:00.000Z",
        "date_creation": "2021-02-09T09:00:00.000Z"
    }
]
parent_id = #insert parent id

for _file in FILES:

    # create filter for files based on file name
    f = f'type:eq:file'

    # create request to get search for all files with expiration date greater than November 29th 2020
    r = nodes.search_nodes(search=_file["file"], parentID=parent_id, depthLevel=-1, offset=0, filter=f)

    # perform request with authenticated DRACOON instance
    try:
        file_response = my_dracoon.get(r)
    except core.requests.exceptions.RequestException as e:
        raise SystemExit(e)

    file_list = []

    # if call successful, check populate list
    if file_response.status_code == 200:

        # add files to list
        for file in file_response.json()['items']:
            file_list.append(file)
Exemplo n.º 5
0
        print(login_response.json()["error"])
        print(login_response.json()["error_description"])
    else:
        print(login_response.text)
    sys.exit()  # exit script if login not successful

# create empty file lists (file list for all files, expired files for all expired files)

file_list = []
expired_files = []

# filter for files created for given time interval
f = 'type:eq:file'

# build request to get nodes
r = nodes.search_nodes(parentID=targetID, filter=f, search='*', depthLevel=-1)

# send request
file_response = my_dracoon.get(r)

if file_response.status_code != 200:
    print(f'Error getting file list: {file_response.status_code}')
    print(file_response.text)
    sys.exit()
elif file_response.status_code == 200:
    for file in file_response.json()['items']:
        file_list.append(file)

#get total amount of files
total_files = file_response.json()['range']['total']