# Path: devicecloud/examples/example_helpers.py
# def get_authenticated_dc():
#     while True:
#         base_url = os.environ.get('DC_BASE_URL', 'https://devicecloud.digi.com')
# 
#         username = os.environ.get('DC_USERNAME', None)
#         if not username:
#             username = input("username: ")
# 
#         password = os.environ.get('DC_PASSWORD', None)
#         if not password:
#             password = getpass("password: ")
# 
#         dc = DeviceCloud(username, password, base_url=base_url)
#         if dc.has_valid_credentials():
#             print("Credentials accepted!")
#             return dc
#         else:
#             print("Invalid username or password provided, try again")
# 
# Path: devicecloud/filedata.py
# class FileDataAPI(APIBase):
# class FileDataObject(object):
# class FileDataDirectory(FileDataObject):
# class FileDataFile(FileDataObject):
#     def get_filedata(self, condition=None, page_size=1000):
#     def write_file(self, path, name, data, content_type=None, archive=False,
#                    raw=False):
#     def delete_file(self, path):
#     def walk(self, root="~/"):
#     def from_json(cls, fdapi, json_data):
#     def __init__(self, fdapi, json_data):
#     def delete(self):
#     def get_data(self):
#     def get_type(self):
#     def get_last_modified_date(self):
#     def get_content_type(self):
#     def get_customer_id(self):
#     def get_created_date(self):
#     def get_name(self):
#     def get_path(self):
#     def get_full_path(self):
#     def get_size(self):
#     def from_json(cls, fdapi, json_data):
#     def __init__(self, fdapi, data):
#     def __repr__(self):
#     def walk(self):
#     def write_file(self, *args, **kwargs):
#     def from_json(cls, fdapi, json_data):
#     def __init__(self, fdapi, json_data):
#     def __repr__(self):


from devicecloud.examples.example_helpers import get_authenticated_dc
from devicecloud.filedata import fd_path
import six
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# Copyright (c) 2015-2018 Digi International Inc.


if __name__ == '__main__':
    dc = get_authenticated_dc()

    dc.filedata.write_file("/~/test_dir/", "test_file.txt", six.b("Helllo, world!"), "text/plain")
    dc.filedata.write_file("/~/test_dir/", "test_file2.txt", six.b("Hello, again!"))

    for dirpath, directories, files in dc.filedata.walk("/"):

# Path: devicecloud/examples/example_helpers.py
# def get_authenticated_dc():
#     while True:
#         base_url = os.environ.get('DC_BASE_URL', 'https://devicecloud.digi.com')
# 
#         username = os.environ.get('DC_USERNAME', None)
#         if not username:
#             username = input("username: ")
# 
#         password = os.environ.get('DC_PASSWORD', None)
#         if not password:
#             password = getpass("password: ")
# 
#         dc = DeviceCloud(username, password, base_url=base_url)
#         if dc.has_valid_credentials():
#             print("Credentials accepted!")
#             return dc
#         else:
#             print("Invalid username or password provided, try again")
# 
# Path: devicecloud/filedata.py
# class FileDataAPI(APIBase):
# class FileDataObject(object):
# class FileDataDirectory(FileDataObject):
# class FileDataFile(FileDataObject):
#     def get_filedata(self, condition=None, page_size=1000):
#     def write_file(self, path, name, data, content_type=None, archive=False,
#                    raw=False):
#     def delete_file(self, path):
#     def walk(self, root="~/"):
#     def from_json(cls, fdapi, json_data):
#     def __init__(self, fdapi, json_data):
#     def delete(self):
#     def get_data(self):
#     def get_type(self):
#     def get_last_modified_date(self):
#     def get_content_type(self):
#     def get_customer_id(self):
#     def get_created_date(self):
#     def get_name(self):
#     def get_path(self):
#     def get_full_path(self):
#     def get_size(self):
#     def from_json(cls, fdapi, json_data):
#     def __init__(self, fdapi, data):
#     def __repr__(self):
#     def walk(self):
#     def write_file(self, *args, **kwargs):
#     def from_json(cls, fdapi, json_data):
#     def __init__(self, fdapi, json_data):
#     def __repr__(self):


# Path: devicecloud/examples/filedata_playground.py
from devicecloud.examples.example_helpers import get_authenticated_dc
from devicecloud.filedata import fd_path
import six

# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# Copyright (c) 2015-2018 Digi International Inc.


if __name__ == '__main__':
    dc = get_authenticated_dc()

    dc.filedata.write_file("/~/test_dir/", "test_file.txt", six.b("Helllo, world!"), "text/plain")
    dc.filedata.write_file("/~/test_dir/", "test_file2.txt", six.b("Hello, again!"))

    for dirpath, directories, files in dc.filedata.walk("/"):

        for fd_file in files: