Starting this version, the CTERA SDK uses an asynchronous HTTP library.
Getting Started
Starting this version, the **Gateway** object was renamed to **Edge.** Additionally, instantiating an Edge object automatically enables https. Additionally, this release requires the use of a Context Manager or invoking the logout command to properly shutdown the session.
with Edge('192.168.0.1') as edge: this is a context manager
try:
edge.login('admin', 'your-password')
except CTERAException as error:
print(error)
with GlobalAdmin('corp.gfs.ctera.me') as admin:
try:
admin.login('admin', 'your-password')
except CTERAException as error:
print(error)
Alternatively, you can use:
edge = Edge('192.168.0.1')
try:
edge.login('admin', 'password1!')
except CTERAException as error:
print(error)
edge.logout()
Settings
Next, this version introduces a different way of modifying the SDK settings.
import cterasdk.settings unnecessary if you use: (from cterasdk import *)
"""Disable SSL Verification"""
cterasdk.settings.sessions.management.ssl = False replaced: config['http'].ssl = 'Trust'
"""Whether the Edge Filer should verify the Portal's SSL certificate
- False: do not verify
- True: verify
- 'prompt' (str): Prompt the user
"""
cterasdk.settings.sessions.management.edge.services.ssl = 'prompt'
"""Change the default downloads directory"""
cterasdk.settings.downloads.location = '~/Downloads'
The following commands are no longer needed to ignore certificate errors:
import urllib3
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
Core Methods
If you invoked the core methods directly (e.g., get, put, execute, add, delete) and not through the SDK modules, notice the following changes:
edge.api.get('/config/device') instead of edge.get('/config/device')
edge.api.put('/config/device/location', 'The Moon')
edge.api.execute('/config/cloudsync', 'evictFolder')
Get Multi
If you used the **get_multi** command to retrieve information from the Edge Filer (this section isn’t applicable to the Portal), you may need to add a forward slash.
edge.get_multi('', ['status', 'config']) this will not work anymore
edge.get_multi('/', ['status', 'config']) use this instead
Built-in Types and Enum
Starting this version the **portal_types** and **portal_enum** modules were renamed to **core_types** and **core_enum**. And the **gateway_types** and **gateway_enum** were renamed to **edge_types** and **edge_enum**.
from cterasdk import core_types, core_enum, edge_types, edge_enum this will work
Exceptions
The exceptions module was renamed from exception to exceptions
from cterasdk.exceptions import ... not cterasdk.exception
Creating Directories
Instead of invoking the **mkdir** function with the recurse attribute, there are two methods. One for creating a single directory and one for creating a full path.
user.files.mkdir('My Files/docs') Single folder
user.files.makedirs('My Files/path/to/folder') Create path
Transcribe
The transcribe module was deprecated.
from cterasdk import config
config.transcript['disabled'] = False will no longer work
For the rest of the changes, please refer to the online documentation: https://ctera-python-sdk.readthedocs.io/en/latest/