@sasjs/core 4.9.4 → 4.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -47,7 +47,7 @@ Documentation: https://core.sasjs.io
47
47
 
48
48
  This library will not be used for storing data entries (such as formats or datalines). Where this becomes necessary in the future, a new repo will be created, in order to keep the NPM bundle size down (for the benefit of those looking to embed purely macros in their applications).
49
49
 
50
- #### FCMP library (All Platforms)
50
+ ### FCMP library (All Platforms)
51
51
 
52
52
  - Function and macro names are identical, except for special cases
53
53
  - Prefixes: _mcf_
@@ -217,7 +217,6 @@ If you find this library useful, please leave a [star](https://github.com/sasjs/
217
217
  ![](https://starchart.cc/sasjs/core.svg)
218
218
 
219
219
 
220
-
221
220
  ## Contributors ✨
222
221
  <!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
223
222
  [![All Contributors](https://img.shields.io/badge/all_contributors-10-orange.svg?style=flat-square)](#contributors-)
@@ -74,7 +74,8 @@
74
74
  outds=work.test_results
75
75
  )/*/STORE SOURCE*/;
76
76
  %local ds test_result test_comments del add mod ilist;
77
- %let ilist=%upcase(&sasjs_prefix._FUNCTIONS &ignorelist);
77
+ %let ilist=%upcase(&sasjs_prefix._FUNCTIONS SYS_PROCHTTP_STATUS_CODE
78
+ SYS_PROCHTTP_STATUS_CODE SYS_PROCHTTP_STATUS_PHRASE &ignorelist);
78
79
 
79
80
  /**
80
81
  * this sets up the global vars, it will also enter STRICT mode. If this
@@ -89,7 +90,7 @@
89
90
  create table &scopeds as
90
91
  select name,offset,value
91
92
  from dictionary.macros
92
- where scope="&scope" and name not in (%mf_getquotedstr(&ilist))
93
+ where scope="&scope" and upcase(name) not in (%mf_getquotedstr(&ilist))
93
94
  order by name,offset;
94
95
  %end;
95
96
  %else %if &action=COMPARE %then %do;
@@ -141,4 +142,4 @@
141
142
  drop table &ds;
142
143
  %end;
143
144
 
144
- %mend mp_assertscope;
145
+ %mend mp_assertscope;
@@ -1,7 +1,8 @@
1
1
  /**
2
2
  @file
3
3
  @brief Mechanism for locking tables to prevent parallel modifications
4
- @details Uses a control table to enable ANY table to be locked for updates.
4
+ @details Uses a control table to enable ANY table to be locked for updates
5
+ (not just SAS datasets).
5
6
  Only useful if every update uses the macro! Used heavily within
6
7
  [Data Controller for SAS](https://datacontroller.io).
7
8
 
@@ -15,7 +16,7 @@
15
16
  length is 200 characters.
16
17
  @param [out] ctl_ds= (0) The control table which controls the actual locking.
17
18
  Should already be assigned and available. The definition is available by
18
- running mp_coretable.sas as follows: `%mp_coretable(LOCKTABLE)`.
19
+ running the mddl_dc_locktable.sas macro.
19
20
 
20
21
  @param [in] loops= (25) Number of times to check for a lock.
21
22
  @param [in] loop_secs= (1) Seconds to wait between each lock attempt
@@ -12,7 +12,7 @@
12
12
 
13
13
  %mp_streamfile(contenttype=csv,inloc=/some/where.txt,outname=myfile.txt)
14
14
 
15
- @param [in] contenttype= (TEXTS) Either TEXT, ZIP, CSV, EXCEL
15
+ @param [in] contenttype= (TEXT) Either TEXT, ZIP, CSV, EXCEL
16
16
  @param [in] inloc= /path/to/file.ext to be sent
17
17
  @param [in] inref= fileref of file to be sent (if provided, overrides `inloc`)
18
18
  @param [in] iftrue= (1=1) Provide a condition under which to execute.
@@ -22,6 +22,7 @@
22
22
 
23
23
  <h4> SAS Macros </h4>
24
24
  @li mf_getplatform.sas
25
+ @li mfs_httpheader.sas
25
26
  @li mp_binarycopy.sas
26
27
 
27
28
  @author Allan Bowe
@@ -55,7 +56,7 @@ data _null_;
55
56
  run;
56
57
 
57
58
  %if &contentype=CSV %then %do;
58
- %if (&platform=SASMETA and &streamweb=1) or &platform=SASJS %then %do;
59
+ %if (&platform=SASMETA and &streamweb=1) %then %do;
59
60
  data _null_;
60
61
  rc=stpsrv_header('Content-type','application/csv');
61
62
  rc=stpsrv_header('Content-disposition',"attachment; filename=&outname");
@@ -66,10 +67,14 @@ run;
66
67
  contenttype='application/csv'
67
68
  contentdisp="attachment; filename=&outname";
68
69
  %end;
70
+ %else %if &platform=SASJS %then %do;
71
+ %mfs_httpheader(Content-type,application/csv)
72
+ %mfs_httpheader(Content-disposition,%str(attachment; filename=&outname))
73
+ %end;
69
74
  %end;
70
75
  %else %if &contentype=EXCEL %then %do;
71
76
  /* suitable for XLS format */
72
- %if (&platform=SASMETA and &streamweb=1) or &platform=SASJS %then %do;
77
+ %if (&platform=SASMETA and &streamweb=1) %then %do;
73
78
  data _null_;
74
79
  rc=stpsrv_header('Content-type','application/vnd.ms-excel');
75
80
  rc=stpsrv_header('Content-disposition',"attachment; filename=&outname");
@@ -80,9 +85,13 @@ run;
80
85
  contenttype='application/vnd.ms-excel'
81
86
  contentdisp="attachment; filename=&outname";
82
87
  %end;
88
+ %else %if &platform=SASJS %then %do;
89
+ %mfs_httpheader(Content-type,application/vnd.ms-excel)
90
+ %mfs_httpheader(Content-disposition,%str(attachment; filename=&outname))
91
+ %end;
83
92
  %end;
84
93
  %else %if &contentype=GIF or &contentype=JPEG or &contentype=PNG %then %do;
85
- %if (&platform=SASMETA and &streamweb=1) or &platform=SASJS %then %do;
94
+ %if (&platform=SASMETA and &streamweb=1) %then %do;
86
95
  data _null_;
87
96
  rc=stpsrv_header('Content-type',"image/%lowcase(&contenttype)");
88
97
  run;
@@ -91,15 +100,21 @@ run;
91
100
  filename &outref filesrvc parenturi="&SYS_JES_JOB_URI"
92
101
  contenttype="image/%lowcase(&contenttype)";
93
102
  %end;
103
+ %else %if &platform=SASJS %then %do;
104
+ %mfs_httpheader(Content-type,image/%lowcase(&contenttype))
105
+ %end;
94
106
  %end;
95
107
  %else %if &contentype=HTML %then %do;
96
108
  %if &platform=SASVIYA %then %do;
97
109
  filename &outref filesrvc parenturi="&SYS_JES_JOB_URI" name="_webout.json"
98
110
  contenttype="text/html";
99
111
  %end;
112
+ %else %if &platform=SASJS %then %do;
113
+ %mfs_httpheader(Content-type,text/html)
114
+ %end;
100
115
  %end;
101
116
  %else %if &contentype=TEXT %then %do;
102
- %if (&platform=SASMETA and &streamweb=1) or &platform=SASJS %then %do;
117
+ %if (&platform=SASMETA and &streamweb=1) %then %do;
103
118
  data _null_;
104
119
  rc=stpsrv_header('Content-type','application/text');
105
120
  rc=stpsrv_header('Content-disposition',"attachment; filename=&outname");
@@ -110,9 +125,13 @@ run;
110
125
  contenttype='application/text'
111
126
  contentdisp="attachment; filename=&outname";
112
127
  %end;
128
+ %else %if &platform=SASJS %then %do;
129
+ %mfs_httpheader(Content-type,application/text)
130
+ %mfs_httpheader(Content-disposition,%str(attachment; filename=&outname))
131
+ %end;
113
132
  %end;
114
133
  %else %if &contentype=WOFF or &contentype=WOFF2 or &contentype=TTF %then %do;
115
- %if (&platform=SASMETA and &streamweb=1) or &platform=SASJS %then %do;
134
+ %if (&platform=SASMETA and &streamweb=1) %then %do;
116
135
  data _null_;
117
136
  rc=stpsrv_header('Content-type',"font/%lowcase(&contenttype)");
118
137
  run;
@@ -121,9 +140,12 @@ run;
121
140
  filename &outref filesrvc parenturi="&SYS_JES_JOB_URI"
122
141
  contenttype="font/%lowcase(&contenttype)";
123
142
  %end;
143
+ %else %if &platform=SASJS %then %do;
144
+ %mfs_httpheader(Content-type,font/%lowcase(&contenttype))
145
+ %end;
124
146
  %end;
125
147
  %else %if &contentype=XLSX %then %do;
126
- %if (&platform=SASMETA and &streamweb=1) or &platform=SASJS %then %do;
148
+ %if (&platform=SASMETA and &streamweb=1) %then %do;
127
149
  data _null_;
128
150
  rc=stpsrv_header('Content-type',
129
151
  'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
@@ -136,9 +158,15 @@ run;
136
158
  'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
137
159
  contentdisp="attachment; filename=&outname";
138
160
  %end;
161
+ %else %if &platform=SASJS %then %do;
162
+ %mfs_httpheader(Content-type
163
+ ,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
164
+ )
165
+ %mfs_httpheader(Content-disposition,%str(attachment; filename=&outname))
166
+ %end;
139
167
  %end;
140
168
  %else %if &contentype=ZIP %then %do;
141
- %if (&platform=SASMETA and &streamweb=1) or &platform=SASJS %then %do;
169
+ %if (&platform=SASMETA and &streamweb=1) %then %do;
142
170
  data _null_;
143
171
  rc=stpsrv_header('Content-type','application/zip');
144
172
  rc=stpsrv_header('Content-disposition',"attachment; filename=&outname");
@@ -149,6 +177,10 @@ run;
149
177
  contenttype='application/zip'
150
178
  contentdisp="attachment; filename=&outname";
151
179
  %end;
180
+ %else %if &platform=SASJS %then %do;
181
+ %mfs_httpheader(Content-type,application/zip)
182
+ %mfs_httpheader(Content-disposition,%str(attachment; filename=&outname))
183
+ %end;
152
184
  %end;
153
185
  %else %do;
154
186
  %put %str(ERR)OR: Content Type &contenttype NOT SUPPORTED by &sysmacroname!;
@@ -40,6 +40,12 @@
40
40
  /* now try and assign it */
41
41
  if libname("&libref",,'meta',cats('liburi="',liburi,'";')) ne 0 then do;
42
42
  putlog "&libref could not be assigned";
43
+ putlog liburi=;
44
+ /**
45
+ * Fetch the system message for display in the abort modal. This is
46
+ * not always helpful though. One example, previously received:
47
+ * NOTE: Libref XX refers to the same library metadata as libref XX.
48
+ */
43
49
  call symputx('msg',sysmsg(),'l');
44
50
  if "&mabort"='HARD' then call symputx('mp_abort',1,'l');
45
51
  end;
@@ -61,7 +67,7 @@
61
67
 
62
68
  %if &mp_abort=1 %then %do;
63
69
  %mp_abort(iftrue= (&mp_abort=1)
64
- ,mac=&sysmacroname
70
+ ,mac=mm_assignlib.sas
65
71
  ,msg=&msg
66
72
  )
67
73
  %return;
package/package.json CHANGED
@@ -36,5 +36,5 @@
36
36
  "@sasjs/cli": "3.6.0",
37
37
  "@sasjs/core": "4.4.7"
38
38
  },
39
- "version": "4.9.4"
39
+ "version": "4.12.0"
40
40
  }
@@ -0,0 +1,89 @@
1
+ /**
2
+ @file
3
+ @brief Creates a file on SASjs Drive
4
+ @details Creates a file on SASjs Drive. To use the file as a Stored Program,
5
+ it must have a ".sas" extension.
6
+
7
+ Example:
8
+
9
+ filename stpcode temp;
10
+ data _null_;
11
+ file stpcode;
12
+ put '%put hello world;';
13
+ run;
14
+ %ms_createfile(/some/stored/program.sas, inref=stpcode)
15
+
16
+ @param [in] driveloc The full path to the file in SASjs Drive
17
+ @param [in] inref= (0) The fileref containing the file to create.
18
+ @param [in] mdebug= (0) Set to 1 to enable DEBUG messages
19
+
20
+ <h4> SAS Macros </h4>
21
+ @li mf_getuniquefileref.sas
22
+ @li mf_getuniquename.sas
23
+ @li mp_abort.sas
24
+
25
+ **/
26
+
27
+ %macro ms_createfile(driveloc
28
+ ,inref=0
29
+ ,mdebug=0
30
+ );
31
+
32
+ %local fname0 fname1 boundary fname statcd msg;
33
+ %let fname0=%mf_getuniquefileref();
34
+ %let fname1=%mf_getuniquefileref();
35
+ %let boundary=%mf_getuniquename();
36
+
37
+ data _null_;
38
+ file &fname0 termstr=crlf;
39
+ infile &inref end=eof;
40
+ if _n_ = 1 then do;
41
+ put "--&boundary.";
42
+ put 'Content-Disposition: form-data; name="filePath"';
43
+ put ;
44
+ put "&driveloc";
45
+ put "--&boundary";
46
+ put 'Content-Disposition: form-data; name="file"; filename="ignore.sas"';
47
+ put "Content-Type: text/plain";
48
+ put ;
49
+ end;
50
+ input;
51
+ put _infile_; /* add the actual file to be sent */
52
+ if eof then do;
53
+ put ;
54
+ put "--&boundary--";
55
+ end;
56
+ run;
57
+
58
+ %if &mdebug=1 %then %do;
59
+ data _null_;
60
+ infile &fname0;
61
+ input;
62
+ put _infile_;
63
+ run;
64
+ %end;
65
+
66
+ proc http method='POST' in=&fname0 out=&fname1
67
+ url="&_sasjs_apiserverurl/SASjsApi/drive/file";
68
+ headers "Content-Type"="multipart/form-data; boundary=&boundary";
69
+ %if &mdebug=1 %then %do;
70
+ debug level=1;
71
+ %end;
72
+ run;
73
+
74
+ %let statcd=0;
75
+ data _null_;
76
+ infile &fname1;
77
+ input;
78
+ putlog _infile_;
79
+ if _infile_='{"status":"success"}' then call symputx('statcd',1,'l');
80
+ else call symputx('msg',_infile_,'l');
81
+ run;
82
+
83
+ %mp_abort(
84
+ iftrue=(&statcd=0)
85
+ ,mac=ms_createfile.sas
86
+ ,msg=%superq(msg)
87
+ )
88
+
89
+ %mend ms_createfile;
@@ -0,0 +1,77 @@
1
+ /**
2
+ @file
3
+ @brief Executes a SASjs Server Stored Program
4
+ @details Runs a Stored Program (using POST method) and extracts the webout and
5
+ log from the response JSON.
6
+
7
+ Example:
8
+
9
+ %ms_runstp(/some/stored/program
10
+ ,debug=131
11
+ ,outref=weboot
12
+ )
13
+
14
+ @param [in] pgm The full path to the Stored Program in SASjs Drive (_program
15
+ parameter)
16
+ @param [in] debug= (131) The value to supply to the _debug URL parameter
17
+ @param [in] mdebug= (0) Set to 1 to enable DEBUG messages
18
+ @param [out] outref= (outweb) The output fileref to contain the response JSON
19
+ (will be created using temp engine)
20
+
21
+ <h4> SAS Macros </h4>
22
+ @li mf_getuniquefileref.sas
23
+ @li mp_abort.sas
24
+
25
+ **/
26
+
27
+ %macro ms_runstp(pgm
28
+ ,debug=131
29
+ ,outref=outweb
30
+ ,mdebug=0
31
+ );
32
+ %local dbg fname1;
33
+ %if &mdebug=1 %then %do;
34
+ %put &sysmacroname entry vars:;
35
+ %put _local_;
36
+ %end;
37
+ %else %let dbg=*;
38
+ %let fname1=%mf_getuniquefileref();
39
+
40
+ %mp_abort(iftrue=("&pgm"="")
41
+ ,mac=&sysmacroname
42
+ ,msg=%str(Program not provided)
43
+ )
44
+
45
+ data _null_;
46
+ file &fname1;
47
+ infile "&_sasjs_tokenfile";
48
+ input;
49
+ put 'Authorization: Bearer' _infile_;
50
+ run;
51
+
52
+ filename &outref temp;
53
+
54
+ /* prepare request*/
55
+ proc http method='POST' headerin=&fname1 out=&outref
56
+ url="&_sasjs_apiserverurl.&_sasjs_apipath?_program=&pgm%str(&)_debug=131";
57
+ run;
58
+ %if (&SYS_PROCHTTP_STATUS_CODE ne 200 and &SYS_PROCHTTP_STATUS_CODE ne 201)
59
+ or &mdebug=1 %then %do;
60
+ data _null_;infile &outref;input;putlog _infile_;run;
61
+ %end;
62
+ %mp_abort(
63
+ iftrue=(&SYS_PROCHTTP_STATUS_CODE ne 200 and &SYS_PROCHTTP_STATUS_CODE ne 201)
64
+ ,mac=&sysmacroname
65
+ ,msg=%str(&SYS_PROCHTTP_STATUS_CODE &SYS_PROCHTTP_STATUS_PHRASE)
66
+ )
67
+
68
+
69
+ %if &mdebug=1 %then %do;
70
+ %put &sysmacroname exit vars:;
71
+ %put _local_;
72
+ %end;
73
+ %else %do;
74
+ /* clear refs */
75
+ filename &fname1 clear;
76
+ %end;
77
+ %mend ms_runstp;
@@ -1,10 +1,10 @@
1
1
  /**
2
2
  @file mv_registerclient.sas
3
3
  @brief Register Client and Secret (admin task)
4
- @details When building apps on SAS Viya, an client id and secret are sometimes
5
- required. In order to generate them, filesystem access to the Consul Token
6
- is needed (it is not enough to be in the SASAdministrator group in SAS
7
- Environment Manager).
4
+ @details When building apps on SAS Viya, a client id and secret are usually
5
+ required. In order to generate them, the Consul Token is required. To access
6
+ this token, you need to be a system administrator (it is not enough to be in
7
+ the SASAdministrator group in SAS Environment Manager).
8
8
 
9
9
  If you are registering a lot of clients / secrets, you may find it more
10
10
  convenient to use the [Viya Token Generator]
@@ -25,51 +25,56 @@
25
25
  "https://raw.githubusercontent.com/sasjs/core/main/all.sas";
26
26
  %inc mc;
27
27
 
28
+ %* generate random client using consul token as input parameter;
29
+ %mv_registerclient(consul_token=12x34sa43v2345n234lasd)
30
+
31
+ %* generate random client details with all scopes;
32
+ %mv_registerclient(scopes=openid *)
33
+
28
34
  %* specific client with just openid scope;
29
35
  %mv_registerclient(client_id=YourClient
30
36
  ,client_secret=YourSecret
31
37
  ,scopes=openid
32
38
  )
33
39
 
34
- %* generate random client details with all scopes;
35
- %mv_registerclient(scopes=openid *)
36
-
37
40
  %* generate random client with 90/180 second access/refresh token expiry;
38
41
  %mv_registerclient(scopes=openid *
39
42
  ,access_token_validity=90
40
43
  ,refresh_token_validity=180
41
44
  )
42
45
 
43
- @param client_id= The client name. Auto generated if blank.
44
- @param client_secret= Client secret. Auto generated if client is blank.
45
- @param scopes=(openid) List of space-seperated unquoted scopes
46
- @param grant_type=(authorization_code|refresh_token) Valid values are
47
- "password" or "authorization_code" (unquoted)
48
- @param outds=(mv_registerclient) The dataset to contain the registered client
49
- id and secret
50
- @param access_token_validity=(DEFAULT) The duration of validity of the access
51
- token in seconds. A value of DEFAULT will omit the entry (and use system
52
- default)
53
- @param refresh_token_validity=(DEFAULT) The duration of validity of the
46
+ @param [in,out] client_id= The client name. Auto generated if blank.
47
+ @param [in,out] client_secret= Client secret. Auto generated if client is
48
+ blank.
49
+ @param [in] consul_token= (0) Provide the actual consul token value here if
50
+ using Viya 4 or above.
51
+ @param [in] scopes= (openid) List of space-seperated unquoted scopes
52
+ @param [in] grant_type= (authorization_code|refresh_token) Valid values are
53
+ "password" or "authorization_code" (unquoted). Pipe seperated.
54
+ @param [out] outds=(mv_registerclient) The dataset to contain the registered
55
+ client id and secret
56
+ @param [in] access_token_validity= (DEFAULT) The access token duration in
57
+ seconds. A value of DEFAULT will omit the entry (and use system default)
58
+ @param [in] refresh_token_validity= (DEFAULT) The duration of validity of the
54
59
  refresh token in seconds. A value of DEFAULT will omit the entry (and use
55
60
  system default)
56
- @param name= An optional, human readable name for the client
57
- @param required_user_groups= A list of group names. If a user does not belong
58
- to all the required groups, the user will not be authenticated and no tokens
59
- are issued to this client for that user. If this field is not specified,
60
- authentication and token issuance proceeds normally.
61
- @param autoapprove= During the auth step the user can choose which scope to
62
- apply. Setting this to true will autoapprove all the client scopes.
63
- @param use_session= If true, access tokens issued to this client will be
61
+ @param [in] client_name= (DEFAULT) An optional, human readable name for the
62
+ client.
63
+ @param [in] required_user_groups= A list of group names. If a user does not
64
+ belong to all the required groups, the user will not be authenticated and no
65
+ tokens are issued to this client for that user. If this field is not
66
+ specified, authentication and token issuance proceeds normally.
67
+ @param [in] autoapprove= During the auth step the user can choose which scope
68
+ to apply. Setting this to true will autoapprove all the client scopes.
69
+ @param [in] use_session= If true, access tokens issued to this client will be
64
70
  associated with an HTTP session and revoked upon logout or time-out.
65
- @param outjson= (_null_) A dataset containing the lines of JSON submitted.
66
- Useful for debugging.
71
+ @param [out] outjson= (_null_) A dataset containing the lines of JSON
72
+ submitted. Useful for debugging.
67
73
 
68
74
  @version VIYA V.03.04
69
75
  @author Allan Bowe, source: https://github.com/sasjs/core
70
76
 
71
77
  <h4> SAS Macros </h4>
72
- @li mp_abort.sas
73
78
  @li mf_getplatform.sas
74
79
  @li mf_getuniquefileref.sas
75
80
  @li mf_getuniquelibref.sas
@@ -81,6 +86,7 @@
81
86
 
82
87
  %macro mv_registerclient(client_id=
83
88
  ,client_secret=
89
+ ,consul_token=0
84
90
  ,client_name=DEFAULT
85
91
  ,scopes=openid
86
92
  ,grant_type=authorization_code|refresh_token
@@ -92,33 +98,40 @@
92
98
  ,refresh_token_validity=DEFAULT
93
99
  ,outjson=_null_
94
100
  );
95
- %local consul_token fname1 fname2 fname3 libref access_token url tokloc;
101
+ %local fname1 fname2 fname3 libref access_token url tokloc;
96
102
 
97
103
  %if client_name=DEFAULT %then %let client_name=
98
- Generated by %mf_getuser() on %sysfunc(datetime(),datetime19.) using SASjs;
104
+ Generated by %mf_getuser() (&sysuserid) on %sysfunc(datetime(),datetime19.
105
+ ) using SASjs;
99
106
 
100
107
  options noquotelenmax;
101
- /* first, get consul token needed to get client id / secret */
102
- %let tokloc=/etc/SASSecurityCertificateFramework/tokens/consul/default;
103
- %let tokloc=%mf_loc(VIYACONFIG)&tokloc/client.token;
104
108
 
109
+ %if "&consul_token"="0" %then %do;
110
+ /* first, get consul token needed to get client id / secret */
111
+ %let tokloc=/etc/SASSecurityCertificateFramework/tokens/consul/default;
112
+ %let tokloc=%mf_loc(VIYACONFIG)&tokloc/client.token;
105
113
 
106
- %mp_abort(iftrue=(%sysfunc(fileexist(&tokloc))=0)
107
- ,mac=&sysmacroname
108
- ,msg=%str(Unable to access the consul token at &tokloc)
109
- )
114
+ %if %sysfunc(fileexist(&tokloc))=0 %then %do;
115
+ %put &sysmacroname: unable to access the consul token at &tokloc;
116
+ %put Try passing the value in the consul= macro parameter;
117
+ %put See docs: https://core.sasjs.io/mv__registerclient_8sas.html;
118
+ %abort;
119
+ %end;
110
120
 
111
- %let consul_token=0;
112
- data _null_;
113
- infile "&tokloc";
114
- input token:$64.;
115
- call symputx('consul_token',token);
116
- run;
121
+ data _null_;
122
+ infile "&tokloc";
123
+ input token:$64.;
124
+ call symputx('consul_token',token);
125
+ run;
117
126
 
118
- %mp_abort(iftrue=("&consul_token"="0")
119
- ,mac=&sysmacroname
120
- ,msg=%str(Unable to source the consul token from &tokloc)
121
- )
127
+ %if "&consul_token"="0" %then %do;
128
+ %put &sysmacroname: Unable to source the consul token from &tokloc;
129
+ %put It seems your account (&sysuserid) does not have admin rights;
130
+ %put Please speak with your platform adminstrator;
131
+ %put Docs: https://core.sasjs.io/mv__registerclient_8sas.html;
132
+ %abort;
133
+ %end;
134
+ %end;
122
135
 
123
136
  %local base_uri; /* location of rest apis */
124
137
  %let base_uri=%mf_getplatform(VIYARESTAPI);
@@ -131,6 +144,9 @@ proc http method='POST' out=&fname1
131
144
  headers "X-Consul-Token"="&consul_token";
132
145
  run;
133
146
 
147
+ %put &=SYS_PROCHTTP_STATUS_CODE;
148
+ %put &=SYS_PROCHTTP_STATUS_PHRASE;
149
+
134
150
  %let libref=%mf_getuniquelibref();
135
151
  libname &libref JSON fileref=&fname1;
136
152