@@ -18,7 +18,7 @@ class Folders(Service):
18
18
19
19
_SERVICE_ROOT = "/folders"
20
20
21
- list_folders , get_folder , update_folder , delete_folder = Service ._crud_funcs (
21
+ list_folders , _get_folder , update_folder , delete_folder = Service ._crud_funcs (
22
22
"/folders" , "folder"
23
23
)
24
24
@@ -61,3 +61,33 @@ def create_folder(cls, name, parent=None, description=None):
61
61
params = {"parentFolderUri" : parent_uri },
62
62
headers = {"Content-Type" : "application/vnd.sas.content.folder+json" },
63
63
)
64
+
65
+ @classmethod
66
+ def get_folder (cls , folder , refresh = False ):
67
+ """Return a folder instance.
68
+
69
+ Parameters
70
+ ----------
71
+ folder : str or dict
72
+ Name, ID, or dictionary representation of the folder.
73
+ refresh : bool, optional
74
+ Obtain an updated copy of the folder.
75
+
76
+ Returns
77
+ -------
78
+ RestObj or None
79
+ A dictionary containing the folder attributes or None.
80
+
81
+ Notes
82
+ -------
83
+ If `folder` is a complete representation of the folder it will be
84
+ returned unless `refresh` is set. This prevents unnecessary REST
85
+ calls when data is already available on the client.
86
+
87
+ """
88
+ # If users pass in a folder name like "/Public" instead of "Public"
89
+ # then just cleanup the folder name so that it matches what's returned by Viya.
90
+ if isinstance (folder , str ):
91
+ folder = folder .strip ("/" )
92
+
93
+ return cls ._get_folder (folder , refresh = refresh )
0 commit comments