File tree Expand file tree Collapse file tree 3 files changed +84
-0
lines changed Expand file tree Collapse file tree 3 files changed +84
-0
lines changed Original file line number Diff line number Diff line change 106
106
< script src ="./js/utility/submit-sas-code.js "> </ script >
107
107
< script src ="./js/utility/get-sas-job-state.js "> </ script >
108
108
< script src ="./js/utility/get-URL-search-parameters.js "> </ script >
109
+ < script src ="./js/utility/get-model-variables.js "> </ script >
110
+ < script src ="./js/utility/delete-model-variable.js "> </ script >
109
111
110
112
<!-- Import Object Builder -->
111
113
< script src ="./js/objects/add-text-objects.js "> </ script >
Original file line number Diff line number Diff line change
1
+ /**
2
+ * Delete a specifc model content file
3
+ *
4
+ * @param {String } VIYAHOST - The Host URL of the SAS Viya Host
5
+ * @param {String } modelID - The ID of the model from which the content should be deleted
6
+ * @param {String } variableID - The ID of the variable that should be deleted
7
+ * @returns {Promise/Object of Client deletion Response } - Returns a Promise that should resolve into a status code
8
+ */
9
+ async function deleteModelVariable ( VIYAHOST , modelID , variableID ) {
10
+ let DELETEMODELVARIABLERESPONSE = await fetch (
11
+ `${ VIYAHOST } /modelRepository/models/${ modelID } /variables/${ variableID } ` ,
12
+ {
13
+ // mode: 'no-cors',
14
+ method : 'delete' ,
15
+ headers : {
16
+ 'Accept' : '*/*' ,
17
+ 'X-CSRF-TOKEN' :
18
+ document ?. csrfToken != undefined ? document . csrfToken : ''
19
+ } ,
20
+ credentials : 'include'
21
+ }
22
+ ) ;
23
+ if ( ! DELETEMODELVARIABLERESPONSE . ok ) {
24
+ if (
25
+ DELETEMODELVARIABLERESPONSE . status === 403 &&
26
+ DELETEMODELVARIABLERESPONSE . headers . get ( 'x-forbidden-reason' ) === 'CSRF'
27
+ ) {
28
+ let h = DELETEMODELVARIABLERESPONSE . headers . get ( 'x-csrf-header' ) ;
29
+ let t = DELETEMODELVARIABLERESPONSE . headers . get ( 'x-csrf-token' ) ;
30
+ document . csrfToken = t ;
31
+ DELETEMODELVARIABLERESPONSE = await fetch (
32
+ `${ VIYAHOST } /modelRepository/models/${ modelID } /variables/${ variableID } ` ,
33
+ {
34
+ // mode: 'no-cors',
35
+ method : 'delete' ,
36
+ headers : {
37
+ 'Accept' : '*/*' ,
38
+ 'X-CSRF-TOKEN' : t ,
39
+ } ,
40
+ credentials : 'include' ,
41
+ }
42
+ ) ;
43
+ }
44
+ }
45
+
46
+ return DELETEMODELVARIABLERESPONSE . status
47
+ }
Original file line number Diff line number Diff line change
1
+ /**
2
+ * Returns a list of Model Manager project models
3
+ *
4
+ * @param {String } VIYAHOST - The Host URL of the SAS Viya Host
5
+ * @param {String } modelID - UUID of the SAS Model Manager model
6
+ * @param {Integer } start - Optional - Specify from where the request should start - default is 0
7
+ * @param {Integer } limit - Optional - Specify how many items should be requested at a time - default is 1000
8
+ * @returns {Promise/Array of SAS Model Manager Model Variables } - Returns a Promise that should resolve into a list of SAS Model Manager Model Variables
9
+ */
10
+ async function getModelVariables (
11
+ VIYAHOST ,
12
+ modelID ,
13
+ start = 0 ,
14
+ limit = 1000
15
+ ) {
16
+
17
+ // Get the variables of a model
18
+ const modelVariablesResponse = await fetch (
19
+ `${ VIYAHOST } /modelRepository/models/${ modelID } /variables?start=${ start } &limit=${ limit } ` ,
20
+ {
21
+ // mode: 'no-cors',
22
+ method : 'get' ,
23
+ headers : {
24
+ 'X-Requested-With' : 'XMLHttpRequest' ,
25
+ Accept : 'application/json' ,
26
+ 'Content-Type' : 'application/json' ,
27
+ } ,
28
+ credentials : 'include' ,
29
+ }
30
+ ) ;
31
+
32
+ // Parse the response
33
+ const modelVariablesItems = await modelVariablesResponse . json ( ) ;
34
+ return modelVariablesItems ?. items ;
35
+ }
You can’t perform that action at this time.
0 commit comments