solidfire.common package¶
Submodules¶
solidfire.common.model module¶
-
class
solidfire.common.model.DataObject(**kwargs)[source]¶ Bases:
solidfire.common.model.ModelPropertyDataObject is the base type for all generated types, including the MetaData properties, as described from the api descriptors.
-
classmethod
extract(data, strict=True)[source]¶ Converts json to a DataObject.
Parameters: - data (str) – json data to be deserialized back to a DataObject
- strict (bool) – If True, missing values will raise an error, otherwise, missing values will None or empty.
Returns: a class deserialized from the data provided.
-
classmethod
-
class
solidfire.common.model.MetaDataObject(name, bases, classdict)[source]¶ Bases:
typeMetaDataObject defines a method for attributing ModelProperties to a type.
-
class
solidfire.common.model.ModelProperty(member_name, member_type, array=False, optional=False, documentation=None, dictionaryType=None)[source]¶ Bases:
objectModelProperty metadata container for API data type information.
ModelProperty constructor.
Parameters: - member_name (str) – the name of the property.
- member_type (str) – the type of the property.
- array (bool) – is the property an array.
- optional (bool) – is the property optional.
- documentation (str) – documentation for the property.
-
extend_json(out, data)[source]¶ Serialize the property as json-like structure.
Parameters: - out – the resulting output.
- data – the data to be converted.
-
extract_from(data)[source]¶ Deserialize the property from json.
Parameters: data – the data to be converted. Returns: the extracted data.
-
solidfire.common.model.extract(typ, src)[source]¶ DataObject value type converter.
Parameters: - typ – the type to extract.
- src – the source to extract as type typ.
Returns: if the type has the ability to extract (convert), otherwise the original version is returned.
-
solidfire.common.model.property(member_name, member_type, array=False, optional=False, documentation=None, dictionaryType=None)[source]¶ Constructs the type for a DataObject property.
Parameters: - member_name (str) – the name of the property.
- member_type (type) – the type of the property.
- array (bool) – is the property an array.
- optional (bool) – is the property optional.
- documentation (str or NoneType) – documentation for the property.
Returns: the constructed type of a property
Module contents¶
API Common Library
-
exception
solidfire.common.ApiMethodVersionError(method_name, api_version, since, deprecated=None)[source]¶ Bases:
exceptions.ExceptionAn ApiMethodVersionError occurs when a service method is not compatible with the version of the connected server.
ApiMethodVersionError constructor.
Parameters: - method_name (str) – name of the service method where the error occurred.
- api_version (str or float) – the version of API used to instantiate the connection to the server.
- since (str or float) – the earliest version of the API a service method is compatible.
- deprecated (str or float) – the latest version of the API that a method is compatible.
-
api_version¶ The version of the Element API Service
-
deprecated¶ The version a service was deprecated
-
method_name¶ The name of the service method causing the error.
-
since¶ The version a service was introduced
-
exception
solidfire.common.ApiParameterVersionError(method_name, api_version, params)[source]¶ Bases:
exceptions.ExceptionAn ApiParameterVersionError occurs when a parameter supplied to a service method is not compatible with the version of the connected server.
ApiParameterVersionError constructor.
Parameters: - method_name (str) – name of the service method where the error occurred.
- api_version (str or float) – the version of API used to instantiate the connection to the server.
- params (list of tuple) – the list of incompatible parameters provided to a service method call. This tuple should include name, value, since, and deprecated values for each offending parameter.
-
api_version¶ The version of the Element API Service
-
method_name¶ The name of the service method causing the error.
-
params¶ The parameters checked with a service call
-
violations¶ The parameters violated with the service call
-
exception
solidfire.common.ApiServerError(method_name, err_json)[source]¶ Bases:
exceptions.ExceptionApiServerError is an exception that occurs on the server and is passes as a response back to the sdk.
ApiServerError constructor.
Parameters: - method_name (str) – name of the service method where the error occurred.
- err_json (str) – the json formatted error received from the service.
-
error_code¶ The numeric code for this error.
-
error_name¶ The name of the error.
-
message¶ A user-friendly message returned from the server.
-
method_name¶ The name of the service method causing the error.
-
exception
solidfire.common.ApiVersionExceededError(api_version, current_version)[source]¶ Bases:
exceptions.ExceptionAn ApiVersionExceededError occurs when connecting to a server with a version lower then the provided api_version.
ApiVersionExceededError constructor.
Parameters: - api_version (str or float) – the version of API used to instantiate the connection to the server.
- current_version (float) – the current version of the server.
-
api_version¶ The version of the Element API Service
-
current_version¶ The current version of the connected Element OS
-
exception
solidfire.common.ApiVersionUnsupportedError(api_version, supported_versions)[source]¶ Bases:
exceptions.ExceptionAn ApiVersionUnsupportedError occurs when connecting to a server unable to support the provided api_version.
ApiVersionUnsupportedError constructor.
Parameters: - api_version (str or float) – the version of API used to instantiate the connection to the server.
- supported_versions (float[]) – the list of supported versions provided by a server.
-
api_version¶ The version of the Element API Service
-
supported_versions¶ The versions supported by the connected Element OS
-
class
solidfire.common.CurlDispatcher(endpoint, username, password, verify_ssl)[source]¶ Bases:
objectThe CurlDispatcher is responsible for connecting, sending, and receiving data to a server.
The CurlDispatcher constructor.
Parameters: - endpoint (str) – the server URL
- username (str) – the username for authentication
- password (str) – the password for authentication
- verify_ssl (bool) – If True, ssl errors will cause an exception to be raised, otherwise, if False, they are ignored.
-
connect_timeout(timeout_in_sec)[source]¶ Set the time to wait for a connection to be established before timeout.
Parameters: timeout_in_sec (int) – the connection timeout in seconds. Raises: ValueError – if timeout_in_sec is less than 0
-
post(data)[source]¶ Post data to the associated endpoint and await the server’s response.
Parameters: data (str or json) – the data to be posted.
-
class
solidfire.common.ServiceBase(mvip=None, username=None, password=None, api_version=8.0, verify_ssl=True, dispatcher=None)[source]¶ Bases:
objectThe base type for API services. This performs the sending, encoding and decoding of requests.
Constructor for initializing a connection to an instance of Element OS
Parameters: - mvip (str) – the management IP (IP or hostname)
- username (str) – username use to connect to the Element OS instance.
- password (str) – authentication for username
- api_version (float) – specific version of Element OS to connect.
- verify_ssl (bool) – disable to avoid ssl connection errors especially when using an IP instead of a hostname
- dispatcher – a prebuilt or custom http dispatcher
Returns: a configured connection to an Element OS instance
-
api_version¶ Returns the version of the Element API
Returns: the version of the Element API Return type: float
-
connect_timeout(timeout_in_sec)[source]¶ Set the time to wait for a connection to be established before timeout.
Parameters: timeout_in_sec (int) – the connection timeout in seconds. Raises: ValueError – if timeout_in_sec is less than 0
-
restore_timeout_defaults()[source]¶ Restores the Connection and Read Timeout to their original durations of 300 seconds (5 minutes) each.
-
send_request(method_name, result_type, params=None, since=None, deprecated=None, return_response_raw=False)[source]¶ Parameters: - method_name (str) – the name of the API method to call
- result_type (DataObject) – the type of the result object returned from the API method called.
- params (dict) – the parameters supplied to the API call.
- since (str or float) – the first version this service was available
- deprecated (str or float) – the final version this service was available
Returns: the result of the API service call
Return type: