sasctl.services.cas_management#
- class sasctl._services.cas_management.CASManagement[source]#
Bases:
Service
The CAS Management service provides the ability to manage and perform actions on common resources as they relate to Cloud Analytic Services (CAS).
- classmethod create_session(properties: dict, server: str | None = None)[source]#
Creates a new session on the CAS server.
- classmethod del_table(name: str, query_params: dict | None = None, caslib: str | None = None, server: str | None = None)[source]#
Deletes a table from Caslib source. Note that is not an unload. This operation physically removes the source table (if the source is writable). For path-based caslibs, this physically removes the file.
- Parameters:
name (str) – Name of the table.
query_params (dict) – Query parameters. The allowed query parameters are sessionId, sourceTableName, quiet, removeAcs. Note that the last three are required.
caslib (str) – Name of the caslib. Defaults to ‘Public’
server (str) – Server where the caslib is registered. Defaults to ‘cas-shared-default’.
- Returns:
RestObj
- Raises:
ValueError – If query_params is empty
- classmethod delete_session(sess_id: str, server: str | None = None, query_params: dict | None = None)[source]#
Terminates a session on the CAS server.
- classmethod get_server(item, refresh=False)#
Return a server instance.
- Parameters:
- Returns:
RestObj or None – A dictionary containing the server attributes or None.
Notes
If item is a complete representation of the server it will be returned unless refresh is set. This prevents unnecessary REST calls when data is already available on the client.
- classmethod get_table(name: str, caslib: str | dict | None = None, server: str | None = None)[source]#
Get a table by name.
- classmethod list_caslibs(server: str | dict, filter_: str | None = None)[source]#
List caslibs available on a server.
- classmethod list_servers(filter=None, start=None, limit=None, **kwargs)#
List all servers available in the environment.
- Parameters:
- Returns:
list – A list of dictionaries containing the servers.
Notes
See the filtering reference for details on the filter parameter.
- classmethod list_sessions(query_params: dict | None = None, server: str | None = None)[source]#
Returns a collection of sessions available on the CAS server.
- classmethod list_tables(caslib: str | dict, server: str | None = None, filter_: str | None = None)[source]#
List tables available in a caslib.
- Parameters:
- Returns:
list – A collection of
RestObj
instances.
- classmethod promote_table(name: str, sess_id: str, caslib: str, server: str | None = None)[source]#
Changes the scope of a loaded CAS table from session to global scope. Operation valid only on a session table. Promote target is the same Caslib that contains the session table.
- classmethod save_table(name: str, caslib: str, properties: dict | None = None, sess_id: str | None = None, server: str | None = None)[source]#
Saves a CAS table to a source table
- Parameters:
name (str) – Name of the table.
sess_id (str) – The session ID
caslib (str) – Name of the caslib.
properties (dict, optional) – Properties of the table. Valid keys are caslibName, format, replace, compress, tableName, sourceTableName, parameters.
server (str) – Server where the caslib is registered. Defaults to ‘cas-shared-default’.
- Returns:
RestObj
- classmethod update_state_table(value: str, name: str, caslib: str | None = None, server: str | None = None, *, query_params: dict | None = None, body: dict | None = None)[source]#
Modifies the state of a table to loaded or unloaded. Returns loaded or unloaded to indicate the state after the operation.
- Parameters:
value (str) – State to which to set the table. Valid values include loaded or unloaded.
name (str) – Name of the table.
caslib (str, optional) – Name of the caslib. Defaults to ‘Public’.
server (str, optional) – Server where the caslib is registered. Defaults to ‘cas-shared-default’.
query_params (dict, optional) – Additional query parameters. Valid keys are sessionId, scope, sourceTableName, createRelationships
body (dict, optional) – Extra instructions providing greater control over the output when a state change to loaded is requested. Valid keys are copies, label, outputCaslibName, outputTableName, parameters, replace, replaceMode, scope.
- Returns:
RestObj
- classmethod upload_file(file: str | TextIO, name: str, caslib: str | None = None, server: str | None = None, header: bool | None = None, format_: str | None = None, *, detail: dict | None = None)[source]#
Upload a file to a CAS table.
Uploads the contents of a CSV, XLS, XLSX, SAS7BDT or SASHDAT file to a newly created CAS table.
- Parameters:
file (str or TextIO) – File containing data to upload or path to the file.
name (str) – Name of the table to create
caslib (str, optional) – caslib in which the table will be created. Defaults to ‘Public’.
server (str, optional) – CAS server on which the table will be created. Defaults to cas-shared-default.
header (bool, optional) – Whether the first row of data contains column headers. Defaults to True.
format (str, optional) – Choose from {“csv”, “xls”, “xlsx”, “sas7bdat”, “sashdat”}. File of input file. Not required if format can be discerned from the file path.
detail (dict, optional) – Additional body parameters. Allowed parameters are ‘sessionId’, ‘variables’, ‘label’, ‘scope’, ‘replace’, ‘encoding’, ‘allowTruncation’, ‘allowEmbeddedNewLines’, ‘delimiter’, ‘varchars’, ‘scanRows’, ‘threadCount’, ‘stripBlanks’, ‘sheetName’, ‘password’, ‘decryptionKey’, ‘stringLengthMultiplier’, ‘varcharConversionThreshold’.
- Returns:
RestObj – Table reference
- sasctl._services.cas_management.check_keys(valid_keys: list, input_keys: list, parameters: str)[source]#
Compares the input_keys against the valid_keys to see if they are allowed to be passed as parameters in the request.
- Parameters:
- Raises:
ValueError – if input_keys are not valid