@@ -114,18 +114,17 @@ module.exports = {
114114 throw new Error ( req . responseText )
115115 }
116116 } ,
117- createVhost : ( url , name , description = "" , tags = [ ] ) => {
117+ createVhost : ( url , authorization , name , description = "" , tags = [ ] ) => {
118118 let vhost = {
119119 "description" : description ,
120120 "tags" : tags
121121 }
122122 log ( "Create vhost " + JSON . stringify ( vhost )
123123 + " with name " + name + " on " + url )
124124 const req = new XMLHttpRequest ( )
125- let base64Credentials = btoa ( 'administrator-only' + ":" + 'guest' )
126125 let finalUrl = url + "/api/vhosts/" + encodeURIComponent ( name )
127126 req . open ( 'PUT' , finalUrl , false )
128- req . setRequestHeader ( "Authorization" , "Basic " + base64Credentials )
127+ req . setRequestHeader ( "Authorization" , authorization )
129128 req . setRequestHeader ( 'Content-Type' , 'application/json' )
130129
131130 req . send ( JSON . stringify ( vhost ) )
@@ -158,13 +157,12 @@ module.exports = {
158157 throw new Error ( req . responseText )
159158 }
160159 } ,
161- deleteVhost : ( url , vhost ) => {
160+ deleteVhost : ( url , authorization , vhost ) => {
162161 log ( "Deleting vhost " + vhost )
163162 const req = new XMLHttpRequest ( )
164- let base64Credentials = btoa ( 'administrator-only' + ":" + 'guest' )
165163 let finalUrl = url + "/api/vhosts/" + encodeURIComponent ( vhost )
166164 req . open ( 'DELETE' , finalUrl , false )
167- req . setRequestHeader ( "Authorization" , "Basic " + base64Credentials )
165+ req . setRequestHeader ( "Authorization" , authorization )
168166
169167 req . send ( )
170168 if ( req . status == 200 || req . status == 204 ) {
@@ -194,21 +192,18 @@ module.exports = {
194192 throw new Error ( req . responseText )
195193 }
196194 } ,
197- createQueue : ( url , name , vhost , queueType = "quorum" ) => {
195+ createQueue : ( url , authorization , vhost , name , arguments = { } ) => {
198196 log ( "Create queue " + JSON . stringify ( name )
199197 + " in vhost " + vhost + " on " + url )
200198 const req = new XMLHttpRequest ( )
201- let base64Credentials = btoa ( 'administrator-only' + ":" + 'guest' )
202199 let finalUrl = url + "/api/queues/" + encodeURIComponent ( vhost ) + "/"
203200 + encodeURIComponent ( name )
204201 req . open ( 'PUT' , finalUrl , false )
205- req . setRequestHeader ( "Authorization" , "Basic " + base64Credentials )
202+ req . setRequestHeader ( "Authorization" , authorization )
206203 req . setRequestHeader ( 'Content-Type' , 'application/json' )
207204 let payload = {
208205 "durable" : true ,
209- "arguments" :{
210- "x-queue-type" : queueType
211- }
206+ "arguments" : arguments
212207 }
213208 req . send ( JSON . stringify ( payload ) )
214209 if ( req . status == 200 || req . status == 204 || req . status == 201 ) {
@@ -219,14 +214,13 @@ module.exports = {
219214 throw new Error ( req . responseText )
220215 }
221216 } ,
222- deleteQueue : ( url , name , vhost ) => {
217+ deleteQueue : ( url , authorization , vhost , name ) => {
223218 log ( "Deleting queue " + name + " on vhost " + vhost )
224219 const req = new XMLHttpRequest ( )
225- let base64Credentials = btoa ( 'administrator-only' + ":" + 'guest' )
226220 let finalUrl = url + "/api/queues/" + encodeURIComponent ( vhost ) + "/"
227221 + encodeURIComponent ( name )
228222 req . open ( 'DELETE' , finalUrl , false )
229- req . setRequestHeader ( "Authorization" , "Basic " + base64Credentials )
223+ req . setRequestHeader ( "Authorization" , authorization )
230224
231225 req . send ( )
232226 if ( req . status == 200 || req . status == 204 ) {
0 commit comments