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).
Methods
create_session
(properties[, server])Creates a new session on the CAS server.
del_table
(name[, query_params, caslib, server])Deletes a table from Caslib source.
delete
(*args, **kwargs)Send a DELETE request.
delete_session
(sess_id[, server, query_params])Terminates a session on the CAS server.
get
(*args, **kwargs)Send a GET request.
get_caslib
(name[, server])Get a caslib by name.
get_link
(obj, rel)Get link information from a resource.
get_server
(item[, refresh])Return a server instance.
get_table
(name[, caslib, server])Get a table by name.
head
(*args, **kwargs)Send a HEAD request.
info
()Version and build information for the service.
is_available
()Check if the service is currently available.
list_caslibs
(server[, filter_])List caslibs available on a server.
list_servers
([filter, start, limit])List all servers available in the environment.
list_sessions
([query_params, server])Returns a collection of sessions available on the CAS server.
list_tables
(caslib[, server, filter_])List tables available in a caslib.
post
(*args, **kwargs)Send a POST request.
promote_table
(name, sess_id, caslib[, server])Changes the scope of a loaded CAS table from session to global scope.
put
(*args, **kwargs)Send a PUT request.
request
(verb, path[, session, format_])Send an HTTP request with a session.
request_link
(obj, rel, **kwargs)Request a link from a resource.
save_table
(name, caslib[, properties, ...])Saves a CAS table to a source table
update_state_table
(value, name[, caslib, ...])Modifies the state of a table to loaded or unloaded.
upload_file
(file, name[, caslib, server, ...])Upload a file to a CAS table.
is_uuid
- classmethod create_session(properties: dict, server: str | None = None)[source]#
Creates a new session on the CAS server.
Parameters#
- propertiesdict
Properties of the session. Valid keys are authenticationType (required), locale, name, nodeCount, timeOut.
- serverstr
Name of the CAS server. Defaults to ‘cas-shared-default’.
- Returns:
- RestObj
- 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:
- namestr
Name of the table.
- query_paramsdict
Query parameters. The allowed query parameters are sessionId, sourceTableName, quiet, removeAcs. Note that the last three are required.
- caslibstr
Name of the caslib. Defaults to ‘Public’
- serverstr
Server where the caslib is registered. Defaults to ‘cas-shared-default’.
- Returns:
- RestObj
- classmethod delete_session(sess_id: str, server: str | None = None, query_params: dict | None = None)[source]#
Terminates a session on the CAS server.
Parameters#
- sess_idstr
A string indicating the Session id.
- serverstr
Name of the CAS server. Defaults to ‘cas-shared-default’.
- query_paramsdict, optional
Query parameters. Valid keys are force, superUserSessionId.
- Returns:
- RestObj
- classmethod get_caslib(name: str, server: str | None = None)[source]#
Get a caslib by name.
- Parameters:
- namestr
Name of the caslib
- serverstr, optional
Name of the CAS server. Defaults to ‘cas-shared-default’.
- Returns:
- RestObj
- classmethod get_server(item, refresh=False)#
Return a server instance.
- Parameters:
- itemstr or dict
Name, ID, or dictionary representation of the server.
- refreshbool, optional
Obtain an updated copy of the server.
- 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.
- Parameters:
- namestr
Name of the table.
- caslibstr or dict, optional
Name, ID, or dictionary representation of the caslib. Defaults to CASUSER.
- serverstr, optional
Server where the caslib is registered.
- Returns:
- RestObj
- 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:
- filterstr, optional
- startint, optional
Zero-based index of the first item to return. Defaults to 0.
- limitint, optional
The maximum number of items to return. Defaults to 20.
- 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.
Parameters#
- query_paramsdict, optional
Query parameters. Valid keys are start, limit, filter, sortBy, excludeItemLink, sessionId.
- serverstr, optional
Name of the CAS server. Defaults to ‘cas-shared-default’.
- Returns:
- list
A collection of
RestObj
instances.
- classmethod list_tables(caslib: str | dict, server: str | None = None, filter_: str | None = None)[source]#
List tables available in a caslib.
- Parameters:
- caslibstr or dict
Name, ID, or dictionary representation of the caslib.
- serverstr, optional
Server where the caslib is registered.
- filter_str, optional
Filter string in the https://developer.sas.com/reference/filtering / format.
- 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.
- Parameters:
- namestr
Name of the table.
- sess_id: str
The session ID
- caslibstr
Name of the caslib.
- serverstr
Server where the caslib is registered. Defaults to ‘cas-shared-default’.
- Returns:
- RestObj
- 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:
- namestr
Name of the table.
- sess_id: str
The session ID
- caslibstr
Name of the caslib.
- propertiesdict, optional
Properties of the table. Valid keys are caslibName, format, replace, compress, tableName, sourceTableName, parameters.
- serverstr
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:
- valuestr
State to which to set the table. Valid values include loaded or unloaded.
- namestr
Name of the table.
- caslibstr, optional
Name of the caslib. Defaults to ‘Public’.
- serverstr, 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
- bodydict, 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:
- filestr or file-like object
File containing data to upload or path to the file.
- namestr
Name of the table to create
- caslibstr, optional
caslib in which the table will be created. Defaults to ‘Public’.
- serverstr, optional
CAS server on which the table will be created. Defaults to cas-shared-default.
- headerbool, optional
Whether the first row of data contains column headers. Defaults to True.
- format_{“csv”, “xls”, “xlsx”, “sas7bdat”, “sashdat”}, optional
File of input file. Not required if format can be discerned from the file path.
- detaildict, 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:
- valid_keys: list
List of allowed parameters
- input_keys: list
List of input parameters
- parameters: str
String describing the type of parameters that are being tested.
- Returns:
- raises ValueError if input_keys are not valid
- sasctl._services.cas_management.check_required_key(required_key: str | list, input_keys: list, parameters: str)[source]#
Check whether the required parameters are in the list of input_key.
- Parameters:
- required_key: str or list
Required parameters
- input_keys: list
The input parameters
- parameters: str
String describing the type of parameters that are being tested.
- Returns:
- raises ValueError if required_key is not present.
- raises TypeError if required_key is neither a list or a string.