SDK operations and objects

Methods and objects for accessing and managing VIANOPS model monitoring functionality and data.

Client subpackages

Submodules

vianops_client.config

class Config(config_path: str | None = None, user: str | None = None, password: str | None = None, webservices_url: str | None = None)

Bases: dict

Class to hold configuration state.

Can be used as a singleton object or as a regular object.

create_auth_header()
get_stacks_from_file()

Read stacks from config file.

Creates a config file if it does not exist.

load_config_from_file(verbose=False, sendauth=True)

Load configuration from the file at path config_path.

Creates the file with default settings if not already present.

Parameters:

sendauth – controls if authentication credentials are sent at all. Useful if an endpoint does not require authentication, but rejects the request anyway when the token is expired. Also, it’s useful for testing.

read_config_file()

Load a config file and return the read object.

Requires that self[“config_path”] is a valid path (can’t be None).

Creates a config file if it does not exist.

set_access_token(access_token)

Update the in-memory access_token. Also, update the access_token in the configuration file if config_path is set.

set_webservices_url(webservices_url)
update_file_global_config(key: str, value)

Update the global section of the config file (not stack specific).

Creates a config file if it does not exist.

update_file_stack_config(key: str, value)

Creates a config file if it does not exist.

write_config_file(config_object)
class ConfiguredBaseApiClass(config: Config | None = None)

Bases: object

Convenience base class for classes that will use configuration values for things like webservices_url and auth_header. To make it easier to use singleton and/or instance configuration objects.

SUCCESS_CODES = (200, 201, 204)
delete(suffix, *args, **kwargs)
get(suffix, *args, **kwargs)
static is_json(myjson)
make_request(requestfn, suffix, success_codes=(200, 201, 204), **kwargs)

Make a web request.

Uses a default authentication header if headers not in kwargs

patch(suffix, *args, **kwargs)
post(suffix, *args, **kwargs)
put(suffix, *args, **kwargs)
get_file_context(filename: IO | Path)
handle_response(response, output_type='object', model=None)
load_from_file(config_path='/home/opc/.config/vianai/config', verbose=False, sendauth=True)
reset_singleton_config(*args, **kwargs)

Re-create the singleton_config.

Causes it to re-load environment variables while updating the singleton config object used by other objects.

vianops_client.convenience

login(webservices_url: str | None = None, user: str | None = None, password: str | None = None, config_path: str | None = None, load_config: bool = False, login: bool = True, verbose: bool = False, sendauth: bool = True)

convenience function for optionally loading a configuration file and logging in.

Creates a configuration file if one does not already exist.

if load_config is True or config_path is not None, will load a config file. If config_path is None, the default config_path will be used.

Args: webservices_url : default if load_config is True or config_path is not None, will load a config file. If config_path is None, the default config_path will be used.

vianops_client.errors

Client exceptions

exception LoginError(msg, response)

Bases: VianRequestError

exception VianError

Bases: Exception

exception VianRequestError(msg, response)

Bases: VianError

vianops_client.vianai_response

pydantic model VianaiErrorResponse

Bases: BaseModel

Show JSON schema
{
   "title": "VianaiErrorResponse",
   "type": "object",
   "properties": {
      "success": {
         "title": "Success",
         "default": false,
         "type": "boolean"
      },
      "error": {
         "title": "Error",
         "type": "string"
      },
      "metadata": {
         "title": "Metadata"
      }
   },
   "required": [
      "error"
   ]
}

Fields:
field error: str [Required]
field metadata: Any | None = None
field success: bool | None = False
pydantic model VianaiSuccessResponse

Bases: BaseModel

Show JSON schema
{
   "title": "VianaiSuccessResponse",
   "type": "object",
   "properties": {
      "success": {
         "title": "Success",
         "type": "boolean"
      },
      "message": {
         "title": "Message"
      }
   },
   "required": [
      "success"
   ]
}

Fields:
field message: Any | None = None
field success: bool [Required]

Module contents