sasctl.services.folders#

class sasctl._services.folders.Folders[source]#

Bases: Service

The Folders API provides an organizational structure for SAS and external content. It can also be used for favorites folders or a history of objects accessed. The resources that are stored in folders (members) use a URI to point back to those resources.

classmethod create_folder(name, parent=None, description=None)[source]#

Create a new folder.

Parameters:
  • name (str) – The name of the new folder

  • parent (str or dict, optional) – The parent folder for this folder, if any. Can be a folder name, id, or dict response from get_folder. If not specified, new folder will be created under root folder.

  • description (str, optional) – A description of the folder

Returns:

RestObj – Details of newly-created folder

classmethod create_path(folder, description=None)[source]#

Create a new folder recursively.

Parameters:
  • folder (str) – The folder to be created including the path.

  • description (str, optional) – A description of the folder

Returns:

RestObj – Details of newly-created folder

classmethod delete_folder(item)#

Delete a folder instance.

Parameters:

item

Returns:

None

classmethod get_folder(folder, refresh=False)[source]#

Return a folder instance.

Parameters:
  • folder (str or dict) –

    May be one of:

    • folder name

    • folder ID

    • folder path

    • folder delegate string

    • dictionary representation of the folder

  • refresh (bool, optional) – Obtain an updated copy of the folder.

Returns:

RestObj or None – A dictionary containing the folder attributes or None.

Notes

If folder is a complete representation of the folder it will be returned unless refresh is set. This prevents unnecessary REST calls when data is already available on the client.

Examples

The following four examples are all functionally equivalent.

>>> get_folder("Public")
{"name": "Public", "id": "4a737209-5662"}
>>> get_folder("/Public")
{"name": "Public", "id": "4a737209-5662"}
>>> get_folder("@public")
{"name": "Public", "id": "4a737209-5662"}
>>> get_folder("@public")
{"name": "Public", "id": "4a737209-5662"}
>>> get_folder("4a737209-5662")
{"name": "Public", "id": "4a737209-5662"}

The full folder path can also be specified.

>>> get_folder("/Public/Demo")
{"name": "Demo", "id": "148081bf-1c86"}

Special folders can be identified using a delegate string. Currently supported are: @myFolder, @appDataFolder, @myHistory, @myFavorites, and @public.

>>> get_folder("@myFolder")
{"name": "My Folder", "id": "71687cd2-db4b"}
classmethod list_folders(filter=None, start=None, limit=None, **kwargs)#

List all folders available in the environment.

Parameters:
  • filter (str, optional)

  • start (int, optional) – Zero-based index of the first item to return. Defaults to 0.

  • limit (int, optional) – The maximum number of items to return. Defaults to 20.

Returns:

list – A list of dictionaries containing the folders.

Notes

See the filtering reference for details on the filter parameter.

classmethod update_folder(item)#

Update a folder instance.

Parameters:

item (dict)

Returns:

None