Merge pull request #130 from volodymyr-babak/master
TB-57: Added support for custom header of REST API Call Plugin
This commit is contained in:
		
						commit
						7d09019fd2
					
				@ -55,6 +55,13 @@ public class RestApiCallPlugin extends AbstractPlugin<RestApiCallPluginConfigura
 | 
				
			|||||||
            this.headers.add(AUTHORIZATION_HEADER_NAME, String.format(AUTHORIZATION_HEADER_FORMAT, new String(token)));
 | 
					            this.headers.add(AUTHORIZATION_HEADER_NAME, String.format(AUTHORIZATION_HEADER_FORMAT, new String(token)));
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (configuration.getHeaders() != null) {
 | 
				
			||||||
 | 
					            configuration.getHeaders().forEach(h -> {
 | 
				
			||||||
 | 
					                log.debug("Adding header to request object. Key = {}, Value = {}", h.getKey(), h.getValue());
 | 
				
			||||||
 | 
					                this.headers.add(h.getKey(), h.getValue());
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        init();
 | 
					        init();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -16,6 +16,9 @@
 | 
				
			|||||||
package org.thingsboard.server.extensions.rest.plugin;
 | 
					package org.thingsboard.server.extensions.rest.plugin;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import lombok.Data;
 | 
					import lombok.Data;
 | 
				
			||||||
 | 
					import org.thingsboard.server.extensions.core.plugin.KeyValuePluginProperties;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.util.List;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@Data
 | 
					@Data
 | 
				
			||||||
public class RestApiCallPluginConfiguration {
 | 
					public class RestApiCallPluginConfiguration {
 | 
				
			||||||
@ -27,4 +30,6 @@ public class RestApiCallPluginConfiguration {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    private String userName;
 | 
					    private String userName;
 | 
				
			||||||
    private String password;
 | 
					    private String password;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private List<KeyValuePluginProperties> headers;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -30,6 +30,24 @@
 | 
				
			|||||||
      "password": {
 | 
					      "password": {
 | 
				
			||||||
        "title": "Password",
 | 
					        "title": "Password",
 | 
				
			||||||
        "type": "string"
 | 
					        "type": "string"
 | 
				
			||||||
 | 
					      },
 | 
				
			||||||
 | 
					      "headers": {
 | 
				
			||||||
 | 
					        "title": "Request Headers",
 | 
				
			||||||
 | 
					        "type": "array",
 | 
				
			||||||
 | 
					        "items": {
 | 
				
			||||||
 | 
					          "title": "Request Header",
 | 
				
			||||||
 | 
					          "type": "object",
 | 
				
			||||||
 | 
					          "properties": {
 | 
				
			||||||
 | 
					            "key": {
 | 
				
			||||||
 | 
					              "title": "Key",
 | 
				
			||||||
 | 
					              "type": "string"
 | 
				
			||||||
 | 
					            },
 | 
				
			||||||
 | 
					            "value": {
 | 
				
			||||||
 | 
					              "title": "Value",
 | 
				
			||||||
 | 
					              "type": "string"
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    "required": [
 | 
					    "required": [
 | 
				
			||||||
@ -62,6 +80,7 @@
 | 
				
			|||||||
    {
 | 
					    {
 | 
				
			||||||
      "key": "password",
 | 
					      "key": "password",
 | 
				
			||||||
      "type": "password"
 | 
					      "type": "password"
 | 
				
			||||||
    }
 | 
					    },
 | 
				
			||||||
 | 
					    "headers"
 | 
				
			||||||
  ]
 | 
					  ]
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user